Understanding this prolog implementation of head

Posted by dmindreader on Stack Overflow See other posts from Stack Overflow or by dmindreader
Published on 2010-04-06T22:27:47Z Indexed on 2010/04/06 22:33 UTC
Read the original article Hit count: 220

Filed under:
head([Y],Y):-!.

head([X|XS],X).

I understand that the head of the list is stored on the variable X.

What does the first clause mean? Is it a cut? Why?

© Stack Overflow or respective owner

Related posts about prolog