IF Computer > MINERVA > Manual > Reference > Functions

Functions

MINERVA
ifcomputer logo
f
Expert Services on the Web

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,
...

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Functions/print_de.html
published 2008/11/17 update 2003/2/28 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS