home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacHaskell 2.2 / progs / demo / prolog / stdlib < prev    next >
Encoding:
Text File  |  1994-09-27  |  1022 b   |  39 lines  |  [TEXT/ttxt]

  1. This file contains a list of predicate definitions that will automatically
  2. be read into Mini Prolog at the beginning of a session.  Each clause in this
  3. file must be entered on a single line and lines containing syntax errors are
  4. always ignored.  This includes the first few lines of this file and provides
  5. a simple way to include comments.
  6.  
  7. append(nil,X,X).
  8. append(cons(X,Y),Z,cons(X,W)):-append(Y,Z,W).
  9.  
  10. equals(X,X).
  11.  
  12. not(X):-X,!,false.
  13. not(X).
  14.  
  15. or(X,Y):-X.
  16. or(X,Y):-Y.
  17.  
  18. and(X,Y):-X,Y.
  19.  
  20. reverse(nil,nil).
  21. reverse(cons(A,X),Y):-and(reverse(X,Z),append(Z,cons(A,nil),Y)).
  22.  
  23. palindromes(X):-and(reverse(X,Y),equals(X,Y)).
  24.  
  25. mul2(A,B):-append(A,A,B).
  26. mul4(A,B):-and(mul2(A,C),mul2(C,B)).
  27. mul8(A,B):-and(mul4(A,C),mul2(C,B)).
  28. mul16(A,B):-and(mul8(A,C),mul2(C,B)).
  29. mul32(A,B):-and(mul16(A,C),mul2(C,B)).
  30. mul64(A,B):-and(mul32(A,C),mul2(C,B)).
  31. mul128(A,B):-and(mul64(A,C),mul2(C,B)).
  32. mul256(A,B):-and(mul128(A,C),mul2(C,B)).
  33. mul512(A,B):-and(mul256(A,C),mul2(C,B)).
  34. mul1024(A,B):-and(mul512(A,C),mul2(C,B)).
  35.  
  36. true.
  37.  
  38. End of stdlib
  39.