[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: srfi-1 map implementation

From: Thien-Thi Nguyen
Subject: Re: srfi-1 map implementation
Date: Sun, 20 Jan 2002 16:56:04 -0800

   From: Panagiotis Vossos <address@hidden>
   Date: Sun, 20 Jan 2002 23:04:15 +0200

   [map1 not tail-recursive; suggested fix]

thanks for finding this!  here is the version of `map1' i will be
installing shortly:

(define (map1 f ls)
  (if (null? ls)
      (let ((ret (list (f (car ls)))))
        (let lp ((ls (cdr ls)) (p ret))         ; tail pointer
          (if (null? ls)
                (set-cdr! p (list (f (car ls))))
                (lp (cdr ls) (cdr p))))))))

i tried this w/ 800, 8000 and 80000, w/ no ill effect except slowness.
probably a better approach would be to name the above `map1-fallback'
and then do:

(define map1 (if (procedure-source map)    ; already munged, don't trust
                 map1-fallback             ; scheme impl
                 map))                     ; (fast) libguile impl

but i'm not sure how reliable `procedure-source' is for this type of
distinction.  also, i would favor a more comprehensive sweep backed by
proper performance testing infrastructure...

   By the way, will the iterative versions be included in the next
   release of guile ?

personally, i'm working on hardware issues on my dev box (triggered by
guile, no less :-), and then plan to do a 1.4.1 release to get some
practice, and then a 1.5.5 release unless some other guile hacker beats
me to it, or convinces me otherwise.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]