I want to multiply two lists, where I take the left list and multiply it by each element of the right list.
For example:
?- multLists([3,4,2], [4,7,8], R).
R = [[12,16,8],[21,28,14],[24,32,16]].
For that I wrote a helper predicate that takes a list and multiplies it by a single scalar:
multListElem([], _, _).
multListElem([H|T], Result, Elem) :-
multListElem(T, W, Elem),
Z is H*Elem,
Result = [Z|W].
But now, when I run ?- multListElem([1,2,3], X, 3).
I get:
1 ?- multListElem([1,2,3], X, 3).
X = [3, 6, 9|_G1840].
What is that weird tail _G1840
?