> In other words, this kind of stack-consuming implementation would be a
> perfectly practical, useful implementation in Racket

Even more than that -- in some cases the simple non-TCO version can be
faster than the usual TCO + reverse-the-accumulator thing.  Here's a
random example:

Welcome to Racket v5.0.99.6.
-> (define (append1 l1 l2) (if (null? l1) l2 (cons (car l1) (append (cdr l1) 
l2))))
-> (define (append2 l1 l2) (let loop ([l1 (reverse l1)] [l2 l2]) (if (null? l1) 
l2 (loop (cdr l1) (cons (car l1) l2)))))
-> (define l1 (make-list 1000000 2))
-> (define l2 (make-list 1000000 2))
-> ,time 11 (for ([i (in-range 20)]) (append1 l1 l2))
;; run #1... -> #<void>
...
;; run #11... -> #<void>
;; 11 runs, 3 best/worst removed, 5 left for average:
;; cpu time: 2529ms = 453ms + 2076ms gc; real time: 2530ms
-> ,time 11 (for ([i (in-range 20)]) (append2 l1 l2))
;; run #1... -> #<void>
...
;; run #11... -> #<void>
;; 11 runs, 3 best/worst removed, 5 left for average:
;; cpu time: 4026ms = 896ms + 3130ms gc; real time: 4026ms


-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to