(load "test.sl") (def Y (λ (f) ((λ (h) (f (λ (x) ((h h) x)))) (λ (h) (f (λ (x) ((h h) x))))))) (def yfib (Y (λ (fib) (λ (n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))))) (def (fib n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2))))) (princ "colorgraph: ")(load "tcolor.sl") (princ "fib(34): ")(assert (equal? (time (fib 34)) 5702887))(princ "yfib(32): ")(assert (equal? (time (yfib 32)) 2178309)) (def (simple-sort l) (if (or (not l) (not (cdr l))) l (let ((piv (car l))) (receive (less grtr) (partition (λ (x) (< x piv)) (cdr l)) (nconc (simple-sort less) (list piv) (simple-sort grtr)))))) (princ "sort: ")(def r (map-int (λ (x) (mod (+ (* x 9421) 12345) 1024)) 1000))(time (simple-sort r)) (princ "macroexpand: ")(time (dotimes (n 5000) (macroexpand '(dotimes (i 100) body1 body2)))) (def (my-append . lsts) (cond ((not lsts) NIL) ((not (cdr lsts)) (car lsts)) (else (letrec ((append2 (λ (l d) (if (not l) d (cons (car l) (append2 (cdr l) d)))))) (append2 (car lsts) (apply my-append (cdr lsts))))))) (princ "append: ")(def L (map-int (λ (x) (map-int identity 20)) 20))(time (dotimes (n 1000) (apply my-append L))) (path-cwd "ast")(princ "p-lambda: ")(load "rpasses.sl")(def *input* (load "datetimeR.sl"))(def *output* NIL)(time (set! *output* (compile-ish *input*)))(assert (equal? *output* (load "rpasses-out.sl")))(path-cwd "..") (show-profiles)
(load "test.sl")
(def Y
(λ (f)
((λ (h)
(f (λ (x) ((h h) x))))
(λ (h)
(f (λ (x) ((h h) x)))))))
(def yfib
(Y (λ (fib)
(λ (n)
(if (< n 2) n (+ (fib (- n 1)) (fib (- n 2))))))))
(def (fib n) (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))
(princ "colorgraph: ")
(load "tcolor.sl")
(princ "fib(34): ")
(assert (equal? (time (fib 34)) 5702887))
(princ "yfib(32): ")
(assert (equal? (time (yfib 32)) 2178309))
(def (simple-sort l)
(if (or (not l) (not (cdr l)))
l
(let ((piv (car l)))
(receive (less grtr)
(partition (λ (x) (< x piv)) (cdr l))
(nconc (simple-sort less)
(list piv)
(simple-sort grtr))))))
(princ "sort: ")
(def r (map-int (λ (x) (mod (+ (* x 9421) 12345) 1024)) 1000))
(time (simple-sort r))
(princ "macroexpand: ")
(time (dotimes (n 5000) (macroexpand '(dotimes (i 100) body1 body2))))
(def (my-append . lsts)
(cond ((not lsts) NIL)
((not (cdr lsts)) (car lsts))
(else (letrec ((append2 (λ (l d)
(if (not l)
d
(cons (car l)
(append2 (cdr l) d))))))
(append2 (car lsts) (apply my-append (cdr lsts)))))))
(princ "append: ")
(def L (map-int (λ (x) (map-int identity 20)) 20))
(time (dotimes (n 1000) (apply my-append L)))
(path-cwd "ast")
(princ "p-lambda: ")
(load "rpasses.sl")
(def *input* (load "datetimeR.sl"))
(def *output* NIL)
(time (set! *output* (compile-ish *input*)))
(assert (equal? *output* (load "rpasses-out.sl")))
(path-cwd "..")
(show-profiles)