Ok, so I'm doing an assignment for school, using prolog.
We're supposed to check if a user-inputted list is even or odd.
So (being more of a Java guy), I thought of using a counter variable (starts at 0, goes up as the program works through the elements of the list), then taking mod 2 of it to see if it's even or odd.
But the problem is that prolog doesn't seem to be capable of storing a number value in a variable, then referring to it later.
Does anyone know how to do that? Or if I'm totally on the wrong track, tell me so. Because I've gone through my book, my notes, the lecture notes and a few online sites, and I still don't know how this works...
--
Captcha: Walk!" inchsta .......Wait, I'm supposed to walk an inch at a time? Silly captcha!
We're supposed to check if a user-inputted list is even or odd.
So (being more of a Java guy), I thought of using a counter variable (starts at 0, goes up as the program works through the elements of the list), then taking mod 2 of it to see if it's even or odd.
But the problem is that prolog doesn't seem to be capable of storing a number value in a variable, then referring to it later.
Does anyone know how to do that? Or if I'm totally on the wrong track, tell me so. Because I've gone through my book, my notes, the lecture notes and a few online sites, and I still don't know how this works...
--
Captcha: Walk!" inchsta .......Wait, I'm supposed to walk an inch at a time? Silly captcha!