can anyone see what this function does?

Code:
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?