| |||||||||||
| Minerva offers 2 built-in predicates for function style evaluation of built-in and user defined predicates.
is/2 arithmetic evaluation <-/2 function evaluation Programming with functions is sometimes easier to write and read than the equivalent predicate. You can define an arithmetic function with a predicate that returns its value in the last argument somearithmetic(Arg1,...,ArgN,Result)and call it either in relational notation with ?- somearithmetic(Arg1,...,ArgN,Result)or in functional notation with ?- Result is somearithmetic(Arg1,...,ArgN).
You can define a general function with a predicate that returns its value in the last argument Predicate(Arg1,...,ArgN,Result)and call it either in relational notation with ?- Predicate(Arg1,...,ArgN,Result)or in functional notation with ?- Result <- Predicate(Arg1,...,ArgN). <-/2 behaves as defined like Res <- Goal :- Goal =.. [Name|Args], append(Args,[Res],XtArgs), XtGoal =.. [Name|XtArgs], call(XtGoal). but is/2 and <-/2 are efficiently implemented builtin predicates of MINERVA. Example with classic Prolog: List <- append([a,b,c],[d,e,f]) Example with a MINERVA Object: Counter <- create_counter(10), Index <- Counter::next, ... | |||||||||||
| |||||||||||
| Back> |
|