Note about the Shen Prolog

36 views
Skip to first unread message

Antti Ylikoski

unread,
May 24, 2015, 4:43:58 PM5/24/15
to qil...@googlegroups.com

There is something which is there in typical LISP based Prolog
implementations, and which I would hope to have available in the Shen
Prolog.  It is the capability to call a Shen function from inside a
Shen Prolog predicate.

This capability is not there in the ISO Prolog.  I think there may be
there a FFI (Foreign Function Interface), but I cannot recall the ISO
standard as well as that.

The below attempt to write the Towers of Hanoi cannot be accomplished,
because there is no way to call the Shen function (output ...) from a
Shen Prolog predicate.

Or, the below program could be done, if there were the Prolog
predicates (write ...) and (writeln ...) in the Shen Prolog.

------------------------------------------------------------

\*
 * The Towers of Hanoi with the Shen Prolog.
 *
 * AJY 2015-05-24
 *
 *\


(defprolog hanoi
  N <-- (hanoi-move N left centre right);)

(defprolog hanoi-move
  0 Ignore1 Ignore2 Ignore3 <--;
  N A B C <--
    (is M (- N 1))
    (hanoi-move M A C B)
    (inform A B)
    (hanoi-move M C B A);)

(defprolog inform
  X Y <--
    (output "~%Move a disc from the ~A pole to the ~A pole.~%"
       X
   Y);)


------------------------------------------------------------

Yours, AJY
Helsinki, Finland

Reply all
Reply to author
Forward
0 new messages