3 ms·
You must be referring to this: ?- member(what, X). X = [what|_G2122] ; X = [_G2121, what|_G2125] ... If what you have isn't a variable, it is tota
by fusiongyro 13y ago
You must be referring to this:
?- member(what, X).
X = [what|_G2122] ;
X = [_G2121, what|_G2125] ...
If what you have isn't a variable, it is totally reasonable:
?- member(what, []).
false.
This is because, lacking other evidence about what X might be, it can't distinguish between making an assertion about a new quantity ("there is a list X which 'what' is a member of") and a query ("is 'what' in the list?"). Making an assertion like that, however, is pretty normal. It's a perfectly reasonable declarative way to understand this behavior, it's just that this thinking is unusual, so it's weird.
Maybe this little demonstration will give the flavor of why you might want this:
?- length(X, 3), member(what, X).
X = [what, _G942, _G945] ;
X = [_G939, what, _G945] ;
X = [_G939, _G942, what].