Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove the first element in list

Tags:

list

prolog

I need to remove the first element from a list (the head). How do I do it?

like image 488
moti malka Avatar asked Mar 10 '11 13:03

moti malka


1 Answers

Maybe something like:

removehead([_|Tail], Tail).

Test:

prolog> removehead([1,2,3,4], R).
[2,3,4]

R is unbound here, and is used for binding it the result.

like image 86
YasirA Avatar answered Sep 28 '22 07:09

YasirA