[plt-dev] I love Haskell (not an April Fools Joke!), feature request for 'for'

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Wed Apr 1 23:01:58 EDT 2009

(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)))))

(define (sort2 l) (sort l (lambda (i j) (< (second i) (second j)))))

-- Matthias



On Apr 1, 2009, at 10:39 PM, David Vanderson wrote:

>
> Matthias Felleisen wrote:
>>> (define (fence s n)
>>>   (define is (shared ((x (append (range 1 n) (range (- n 1) 2)  
>>> x))) x))
>>>   (define wv (for/list ((c s)) (begin0 (list c (car is)) (set! is  
>>> (cdr is)))))
>>>   (map first (sort2 wv)))
>
> I very much enjoyed trying my hand at this problem and then  
> figuring out how this function works.  But I couldn't find "range"  
> or "sort2" in the PLT docs.  Are those functions that seasoned  
> schemers are assumed to know about and have on hand?
>
> Thanks,
> Dave



Posted on the dev mailing list.