Next: Beispiele in zwei Up: Parsen und Generieren der Previous: References

Beispieldialog

Das folgende Scriptfile zeigt eine Beispielsitzung. Man beachte, daß man mittels

eine Datei von der Lisp-artigen in die Prolog-artige Syntax transformieren kann. Dabei gehen Kommentare verloren.


rfi-l> consult higher-order
; Reading file "higher-order.rf" ..
rfi-l> listing
(ft (twice1 _f)
    `(compose _f _f) )
(ft ((twice2 _f) _a)
    (`(compose _f _f) _a) )
(ft ((compose _f _g) | _a)
    (_f (_g | _a)) )
(ft (adofad1)
    (twice1 1+) )
(ft (adofad2)
    `(twice2 1+) )
(ft (add2 _x)
    ((twice1 1+) _x) )
(ft (goal1)
    (`(compose 1+ *) 2 3) )
(ft (goal2)
    (twice1 1+) )
(ft (goal3)
    ((twice1 1+) 0) )
(ft (goal4)
    ((adofad1) 0) )
(ft (goal5)
    (add2 0) )
(ft (goal6)
    (twice1 twice1) )
(ft (goal7)
    (((twice1 twice1) 1+) 0) )
rfi-l> style prolog
rfi-p> listing
twice1(F) :-& compose[F, F].
twice2[F](A) :-& compose[F, F](A).
compose[F, G](| A) :-& F(G(| A)).
adofad1() :-& twice1(1+).
adofad2() :-& twice2[1+].
add2(X) :-& twice1(1+)(X).
goal1() :-& compose[1+, *](2, 3).
goal2() :-& twice1(1+).
goal3() :-& twice1(1+)(0).
goal4() :-& adofad1()(0).
goal5() :-& add2(0).
goal6() :-& twice1(twice1).
goal7() :-& twice1(twice1)(1+)(0).
rfi-p> tell higher-order  % erzeugt die Datei higher-order.rfp
rfi-p>goal1()
7
rfi-p> goal2()
compose[1+, 1+]
rfi-p> goal3()
2
rfi-p> goal4()
2
rfi-p> goal5()
2
rfi-p> goal6()
compose[twice1, twice1]
rfi-p> goal7()
4


Harold Boley & Michael Herfert (herfert@dfki.uni-kl.de)