next up previous contents index
Next: Program Flow Up: Built in functions Previous: Comparison Operators   Contents   Index

List Manipulation

Lists are stored internally as prolog lists

car(L)

returns the first element of a list

  car([a b c d]) => a
[H|T]

forms a list with H as first element and T as tail

  [a|[b c d]] => [a b c d]
cons(H T)

as [H|T] (see above)
cdr(L)

returns the tail of a list (i.e. what remains after removing first element)

  cdr([a b c d]) => [b c d]
  cdr([a|[b c d]]) => [b c d]
reverse(L)

reverses the order of elements in a list


chris mungall 2006-02-09