PDA

Click to See Complete Forum and Search --> : prolog question


Pouncer
Nov 19th, 2005, 08:46 AM
can anyone see what this function does?


take(X,Xs,Ys) :- append(As,[X|Bs],Xs),append(As,Bs,Ys).
append([],Xs,Xs).
append([X|Xs],Ys,[X|Zs]) :- append(Xs,Ys,Zs).


An example of a way to test it is,

take(b,[a,b,b],L).
which gives..
L = [a, b]
L = [a, b]

But im not sure quite whats going on, any ideas anyone? :confused: