I am writing a prolog program to solve a problem. The problem takes three lists as input:
solve( [L|Lr] , [R|Rr] , [S|Sr] ) :-
Unfortunately the lists all need to be equal length for the program to work.
So these work:
?- solve( [A, B, C, D] , [1, 3, 5, 6], [E, F, G, H]).
?- solve( [1] , [2], [3]).
But these do not:
?- solve( [A, B, C, D], [1], [B, I, T] ).
?- solve( [A], [1, 2], [4, 5]).
What I would like to do is write a predicate(?) to pad the smaller lists with leading zeros. So:
solve( [A, B, C, D], [1], [B, I, T] )
would become:
solve( [A, B, C, D], [0, 0, 0, 1], [0, B, I, T] )
Any points on how to accomplish this would be awesome. I am from a functional background so I am struggling. Is there a way tell the length of a list? I think I could do that recursively, but it seems like a pain.
Thanks