pLISP Start Page   pLISP
© '98 Thomas Mahler

Functions for testing Compiler and VM

Some examples for testing compiler and combinator reduction.
this file should only be loaded after the CC Compiler has been loaded
 // define some simple functions for demonstration
 // and benchmarking
 // compute the factorial (fac 4) = 1*2*3*4 = 24
 (define fac (lambda (n)   
   (if (= n 0)
      1
      (* n (fac (-1 n))))))
 // version of factorial for use with Y Combinator (Y facY 4)
 (define facY 
 (lambda (f n) 
   (if (= n 0) 1 (* n (f (-1 n)))))) 
 // compute fibonacci numbers:
 (define fib (lambda (n)
   (if (= n 0) 
      1
      (if (= n 1)
         1
         (+ (fib (-1 n)) (fib (- n 2)))))))
 // version of fib using Y combinator
 (define fibY (lambda (f n)
   (if (= n 0) 
      1
      (if (= n 1)
         1
         (+ (f (-1 n)) (f (- n 2))))))) 
 // (tak 18 12 6) is a nice benchmark fo