(define (f1 x) (+ x 1))
(define (f2 x) (+ x 2))
(define (f3 x) (+ x 3))

(define (f* x) (f1 (f2 (f3 x))))
(define f-comp (compose f1 f2 f3))

(define-syntax-rule (test f)
  (time 
   (for ([i (in-range 100000000)])
     (f i))))

(test f*)
(test f-comp)

---

cpu time: 375 real time: 375 gc time: 0
cpu time: 5109 real time: 5172 gc time: 0

If try 
(define f1 (curry + 1))
(define f2 (curry + 2))
(define f3 (curry + 3))

then even worse:

cpu time: 46796 real time: 46891 gc time: 5241
cpu time: 60860 real time: 60953 gc time: 6945

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to