Help with prolog

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Help with prolog

Postby PeterCai » Mon Jan 31, 2011 8:13 pm UTC

Not a homework question, I am studying prolog by myself, and ran into this problem in an online tutorial.

so the problem is: make a predicate seq(?X,+Y) where Y is a natural number, and X is a natural number smaller than Y.

could someone give me a tip on how to deal with problems like this?

+ means it is instaniated, ? means it may or may not be instantiated.
PeterCai
 
Posts: 870
Joined: Tue Feb 17, 2009 1:09 pm UTC

Re: Help with prolog

Postby b.i.o » Mon Jan 31, 2011 8:47 pm UTC

It's kind of hard to give you a tip without any idea of what you've tried/thought of. First: do you have any experience doing functional programming? (It'll make your life a lot easier, but Prolog doesn't behave like you might expect it would.) Second: what Prolog implementation are you using?
User avatar
b.i.o
Green is the loneliest number
 
Posts: 2514
Joined: Fri Jul 27, 2007 4:38 pm UTC
Location: Hong Kong

Re: Help with prolog

Postby PeterCai » Mon Jan 31, 2011 8:51 pm UTC

b.i.o wrote:It's kind of hard to give you a tip without any idea of what you've tried/thought of. First: do you have any experience doing functional programming? (It'll make your life a lot easier, but Prolog doesn't behave like you might expect it would.) Second: what Prolog implementation are you using?


i have expierence with functional programing. and i am using swi-prolog.
PeterCai
 
Posts: 870
Joined: Tue Feb 17, 2009 1:09 pm UTC

Re: Help with prolog

Postby PeterCai » Mon Jan 31, 2011 11:19 pm UTC

nvm, got it
PeterCai
 
Posts: 870
Joined: Tue Feb 17, 2009 1:09 pm UTC


Return to Coding

Who is online

Users browsing this forum: OmenPigeon, SlefBalia and 10 guests