Prolog基础

Lists in Prolog

  1. ?- X = .(a, .(b, .(c, []))).
    X = [a, b, c]
    Yes
    P.S.Recent versions of SWI-Prolog use ’[|]’ instead of . (dot).
    [a, b, c, d] is the same as [a, b | [c, d]].
  2. ?- MyList = [1, 2, 3, 4, 5], MyList = [1, _ | Rest].

           MyList = [1, 2, 3, 4, 5]Rest = [3, 4, 5]Yes

 
 
 

 
posted @ 2022-03-10 20:38  Clematis  阅读(49)  评论(0)    收藏  举报