home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.yorku.ca 2015
/
ftp.cs.yorku.ca.tar
/
ftp.cs.yorku.ca
/
pub
/
peter
/
SVT
/
forth.simp
< prev
next >
Wrap
Text File
|
2000-01-24
|
477b
|
11 lines
forth(S) ->> forth1(R) :- ensure_loaded(library(lists)), reverse(S, R).
forth1([dup | Rest]) ->> dup(forth1(Rest)).
forth1([over | Rest]) ->> over(forth1(Rest)).
forth1([swap | Rest]) ->> swap(forth1(Rest)).
forth1(['+' | Rest]) ->> plus(forth1(Rest)).
forth1(['-' | Rest]) ->> minus(forth1(Rest)).
forth1(['*' | Rest]) ->> times(forth1(Rest)).
forth1(['/' | Rest]) ->> divide(forth1(Rest)).
forth1([X | Rest]) ->> push(X, forth1(Rest)).
forth1([]) ->> nil.