[plt-scheme] "useless" abstraction

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Mon May 17 10:24:14 EDT 2010

On May 17, 2010, at 10:19 AM, Matthias Felleisen wrote:

> (define-syntax-rule
>  (define/lead (name x n) base combine pfx ...)
>  ;; MF: lead is (- (depth x) n) items, ergo traversing lead leaves
>  ;;     (- (depth x) (- (depth x) n)) = n items to be dealt with
>  ;;     either via a combine ~ cons or an accumulator
>  (let loop ([lead (drop x n)] [x x][pfx '()] ...)
>    (if (pair? lead)
>        (combine (car x) (loop (cdr lead) (cdr x) (cons (car x)  
> pfx) ...))
>        (base x pfx ...))))


Sorry, this one lost a line in translation:

(define-syntax-rule
   (define/lead (name x n) base combine pfx ...)
   ;; MF: lead is (- (depth x) n) items, ergo traversing lead leaves
   ;;     (- (depth x) (- (depth x) n)) = n items to be dealt with
   ;;     either via a combine ~ cons or an accumulator
   (define (name x n)
     (let loop ([lead (drop x n)] [x x][pfx '()] ...)
       (if (pair? lead)
           (combine (car x) (loop (cdr lead) (cdr x) (cons (car x)  
pfx) ...))
           (base x pfx ...)))))




Posted on the users mailing list.