Newb question about variable not completely bound
Posted: 15 Nov 2013 7:26
Hello. I've recently started learning prolog and am testing around some stuff.
Yesterday i got some troubles with reading a list from console. Well, i need to get a list of integers greater then zero. So i'm reading them recursively from console in the first clause and want to fall into the second clause if i read 0 which means user has finished entering the list. But in the second clause i get an error that sais that variable '_' is not completely bound. Searching around the forum didn't help at all (maybe i'm dumb, i'm really sorry if it's so). Please, could you help me just a little bit? :)
Here's a little part of the code that generates that error:
Yesterday i got some troubles with reading a list from console. Well, i need to get a list of integers greater then zero. So i'm reading them recursively from console in the first clause and want to fall into the second clause if i read 0 which means user has finished entering the list. But in the second clause i get an error that sais that variable '_' is not completely bound. Searching around the forum didn't help at all (maybe i'm dumb, i'm really sorry if it's so). Please, could you help me just a little bit? :)
Here's a little part of the code that generates that error:
Code: Select all
read_list([H|L]) :-
H = stdio::read(),
H > 0,
read_list(L).
read_list(_).