* Re: Nested mapcar* application and possibly some variation of Y combinator
[not found] <2caa0c6e-9f98-446b-b5d5-3d09535efc13@f1g2000pre.googlegroups.com>
@ 2012-03-29 8:24 ` WJ
0 siblings, 0 replies; only message in thread
From: WJ @ 2012-03-29 8:24 UTC (permalink / raw)
To: help-gnu-emacs
Swami Tota Ram Shankar wrote:
> Dear elispWizards,
>
> Consider the following command to halve every element in a vector or a
> list
>
> (mapcar* '(lambda(x) (* 0.5 x)) '[1 2 3 4 5 6 7] ) ---> (0.5 1.0
> 1.5 2.0 2.5 3.0 3.5)
>
> Now, I intend to vary it so that it operated like this on a singly
> nested list
>
> (mapcar* '(lambda(x) (* 0.5 x)) '[[1 2 3] [4 5 6 7]] ) --->
> ((0.5 1.0 1.5) (2.0 2.5 3.0 3.5))
>
> It would be nice if this can be accomplished without opening the
> nested list or vector and nesting it again.
>
> I could not put the mapcar* inside the lambda ... maybe made some
> simple mistake. I dont have a strong enough intuition to say if this
> is possible or not.
>
(mapcar (lambda(s) (mapcar (apply-partially '* 0.5) s)) [[1 2][3 4]])
==> ((0.5 1.0) (1.5 2.0))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-03-29 8:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <2caa0c6e-9f98-446b-b5d5-3d09535efc13@f1g2000pre.googlegroups.com>
2012-03-29 8:24 ` Nested mapcar* application and possibly some variation of Y combinator WJ
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.