Re: deepmap?
- From: carl <clumma@xxxxxxxxx>
- Date: Mon, 31 Mar 2008 11:39:26 -0700 (PDT)
On Mar 31, 4:55 am, leppie <xacc....@xxxxxxxxx> wrote:
On Mar 31, 8:49 am, carl <clu...@xxxxxxxxx> wrote:
Hi,
I'm an amateur Schemer (Petite Chez in particular) making a first
post.
I want to do this:
(deepmap min (lambda (x) (car x)) '((3 p) (2 q))) => (2 q)
Like,
(define deepmap
(lambda (proc filter ls)
...))
It seems like something that might require continuations, but I don't
know how to use them.
Any tips would be most appreciated. Thanks,
-Carl
Sorry, didnt know this does not support HTML, here is the text
version.
(define (deepmap p f lst)
(fold-left
(lambda (prev x)
(if prev
(let ((nm (p (f prev) (f x))))
(if (eqv? (f prev) nm)
prev
x))
x))
#f
lst))
Cool, thanks! Using eqv was the insight I missed (duh).
Any reason why not to write it like this
(define deepmap
(lambda (proc filter ls)
(fold-left
(lambda (prev x)
(if (eqv?
(proc (filter prev) (filter x))
(filter prev))
prev
x))
(car ls)
(cdr ls))))
?
-Carl
.
- References:
- deepmap?
- From: carl
- Re: deepmap?
- From: leppie
- deepmap?
- Prev by Date: Re: Scheme eval issues
- Next by Date: Re: Scheme eval issues
- Previous by thread: Re: deepmap?
- Index(es):
Relevant Pages
|