home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / TESTS / LF / SHARE.LF < prev    next >
Text File  |  1996-06-04  |  949b  |  36 lines

  1. % Test: share.lf
  2.  
  3. % Time differences: (unoptimized wild_life on 3Max)
  4. % p2(15)        0.35 s
  5. % ns_p2(15)     0.32 s
  6. % p3(15)      101.25 s
  7. % ns_p3(15)   101.40 s
  8. % Lots of time, but very little stack or heap space used!
  9. % And listing(triple,pair,striple,spair) is immediate, there's no difference
  10. % in time between the four that is not prop. to their respective sizes.
  11. % In other words, (1) copy can be improved by a lot, and
  12. % (2) the implementation of non_strict does not seem to be the problem.
  13.  
  14. share2(0) -> bot.
  15. share2(N) -> spair(X,X) | X=share2(N-1).
  16.  
  17. share3(0) -> bot.
  18. share3(N) -> striple(X,X,X) | X=share3(N-1).
  19.  
  20.  
  21. non_strict(pair)?
  22. non_strict(triple)?
  23.  
  24. ns_share2(0) -> bot.
  25. ns_share2(N) -> pair(X,X) | X=ns_share2(N-1).
  26.  
  27. ns_share3(0) -> bot.
  28. ns_share3(N) -> triple(X,X,X) | X=ns_share3(N-1).
  29.  
  30.  
  31. p2(N) :- A=share2(N), assert(A).
  32. p3(N) :- A=share3(N), assert(A).
  33.  
  34. ns_p2(N) :- A=ns_share2(N), assert(A).
  35. ns_p3(N) :- A=ns_share3(N), assert(A).
  36.