Menu

#9 Multiple returns error

open
nobody
None
5
2012-02-14
2012-02-14
Anonymous
No

When running a simple call like member(1,[1,2,3]) the SWI Interpreter will run through the list [1,2,3] and after having found 1, it will keep looking until the end of the list, hence it will return true, false. It seems like after returning true, the second value false is only being shown if you write ; after, but you do have the option of writing something else instead, which can cause an error

Here is an example of a console sequence that will make it break:
:-member(1,[1,2,3]).
true
:-;
false.
|member(1,[1,2,3]).
true
:-member(1,[1,2,3]).
Unknown action: m (h for help)
Action?
:-

Cheers

Discussion