Page 1 of 1

use function as a variable

Posted: 9 Dec 2013 10:27
by billgates198606
predicates
usefunc(string word,function func{T1,T2})
clauses
run():-
readln(word )
readln(A,B)
usefunc(word,func{T1,T2})
word = update %means if word is update it will call update function
func(A,B) % IF word is delete mean it will call delete function

how do define usefunc(word,func{T1,T2}) 's predicates and its domains
_________________

Posted: 11 Dec 2013 19:44
by Thomas Linder Puls
Have you tried typing the code above into a Visual Prolog file. I think there is at least 20 syntax errors.

Do you know that variables must start with an uppercase letter?

I do not at all understand what you mean by function func{T1, T2}:
  • What is function?
  • What is func?
  • What is T1?
  • What is T2?
By b]readline(word)[/b] I guess that you want to read a line from somewhere and put the result in a variable. But a variable cannot start with a lowercase letter, so word will not work, it must be Word (and when you write it correctly in the editor it will become green: variables are green).

...

Posted: 12 Dec 2013 2:47
by billgates198606
domains
define the domain of func()

predicates
usefunc(string word, domainoffunc func(T1,T2))
clauses
run():-
readln(Word ) ,
readln(A,B) ,
usefunc(word,func(T1,T2))
word = update %means if word is update it will call update function update()
func(A,B) % IF word is delete mean it will call delete function delete()

how do define func(word,func(T1,T2)) how define it's predicates and its domains
_________________

Posted: 12 Dec 2013 12:56
by Paul Cerkez
I get the impression that you are trying to implement something in VIP but are not using the VIP language.

is your Prolog (assuming it is prolog) from another style?

If yes, you need to translate it into the VIP implementation.

To echo what Thomas said, you need to go through the tutorials on the fundimentals. A lot of people on this site will help you along toward understanding but you need to do the the basics first.