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 >
Text File  |  2000-01-24  |  477b  |  11 lines

  1. forth(S) ->> forth1(R) :- ensure_loaded(library(lists)), reverse(S, R).
  2. forth1([dup | Rest]) ->> dup(forth1(Rest)).
  3. forth1([over | Rest]) ->> over(forth1(Rest)).
  4. forth1([swap | Rest]) ->> swap(forth1(Rest)).
  5. forth1(['+' | Rest]) ->> plus(forth1(Rest)).      
  6. forth1(['-' | Rest]) ->> minus(forth1(Rest)).   
  7. forth1(['*' | Rest]) ->> times(forth1(Rest)).       
  8. forth1(['/' | Rest]) ->> divide(forth1(Rest)).   
  9. forth1([X | Rest]) ->> push(X, forth1(Rest)).
  10. forth1([]) ->> nil.
  11.