[plt-dev] range

2009-05-20 Thread Matthias Felleisen
Is there a function that computes such lists: ;; Nat Nat -> [Listof Nat] (define (range lo hi) (if (>= hi lo) (build-list (+ (- hi lo) 1) (lambda (i) (+ lo i))) (build-list (+ (- lo hi) 1) (lambda (i) (- lo i) _ For list-re

Re: [plt-dev] range mini benchmark

2009-05-02 Thread namekuseijin
On Sat, May 2, 2009 at 7:37 PM, namekuseijin wrote: > Seems to me you're measuring consing.  I'm not really a fan of > creating intermediary lists, I enjoy iterators more.  I have my own > version of range, here simplified: > > ; returns an iterator for given range > ;  given an initial result and

Re: [plt-dev] range mini benchmark

2009-05-02 Thread namekuseijin
Seems to me you're measuring consing. I'm not really a fan of creating intermediary lists, I enjoy iterators more. I have my own version of range, here simplified: ; returns an iterator for given range ; given an initial result and a reducer function, will apply it each iteration (define (range

Re: [plt-dev] range mini benchmark

2009-05-02 Thread Eli Barzilay
On May 2, David Van Horn wrote: > Here is a benchmark for a few implementations of `range': > > Nat Nat -> [Listof Nat] > (range 0 5) => (list 0 1 2 3 4 5) > (range 5 0) => (list 5 4 3 2 1 0) > > One uses build-list, another uses sequences. I threw in an > implementation using an i

[plt-dev] range mini benchmark

2009-05-02 Thread David Van Horn
Here is a benchmark for a few implementations of `range': Nat Nat -> [Listof Nat] (range 0 5) => (list 0 1 2 3 4 5) (range 5 0) => (list 5 4 3 2 1 0) One uses build-list, another uses sequences. I threw in an implementation using an iterative build-list as well. I was surprised the