[a,b,c,d] and
[[1,2,3,4],[5,6,7,8],[43,34,56,5],[23,32,2,2]]
I want to make
[[a,1,2,3,4],[b,5,6,7,8],[c,43,34,56,5],[d,23,32,2,2]]
I use swi prolog is it possible do it ?
Thanks a lot.
solve([], [], []).
solve([[X|Y]|S], [X|L1], [Y|L2]):-
solve(S, L1, L2).
UPDATE: How to use
Write the function in a file "a.pl", then in swi-prolog type:
['a.pl'].
then type:
solve(X, [a,b,c,d], [[1,2,3,4],[5,6,7,8],[43,34,56,5],[23,32,2,2]]).
You will get:
X = [[a, 1, 2, 3, 4], [b, 5, 6, 7, 8], [c, 43, 34, 56, 5], [d, 23, 32, 2, 2]]
I have the strange feeling that I am doing your homework. Is it?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With