Re: deepmap?



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
.



Relevant Pages

  • Re: deepmap?
    ... (lambda (proc filter ls) ... (lambda (prev x) ...
    (comp.lang.scheme)
  • Re: Python becoming less Lisp-like
    ... >Basically, it says that it will get rid of the explicit map, filter ... >It will also get rid of lambda, and it's not a great loss, since ... For a while it covered some Python ...
    (comp.lang.python)
  • Re: Python becoming less Lisp-like
    ... >Basically, it says that it will get rid of the explicit map, filter ... >It will also get rid of lambda, and it's not a great loss, since ... For a while it covered some Python ...
    (comp.lang.lisp)
  • Re: Python becoming less Lisp-like
    ... > Basically, it says that it will get rid of the explicit map, filter ... > It will also get rid of lambda, and it's not a great loss, since ... > The real problem with Python is that it has been very successful as a ...
    (comp.lang.python)
  • Re: Python becoming less Lisp-like
    ... > Basically, it says that it will get rid of the explicit map, filter ... > It will also get rid of lambda, and it's not a great loss, since ... > The real problem with Python is that it has been very successful as a ...
    (comp.lang.lisp)