The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Message from discussion Nested mapcar* application and possibly some variation of Y combinator

From:
To:
Cc:
Followup To:
Subject:
 Validation: For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon.

More options Aug 21 2011, 4:19 am
Newsgroups: gnu.emacs.help, comp.lang.lisp, comp.emacs, gnu.emacs, comp.lang.scheme
From: Swami Tota Ram Shankar <tota_...@india.com>
Date: Sun, 21 Aug 2011 01:19:20 -0700 (PDT)
Local: Sun, Aug 21 2011 4:19 am
Subject: Nested mapcar* application and possibly some variation of Y combinator
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.

However, I am inspired by this approach for factorial which I picked
up from somewhere a while ago. Its said that it is a Y combinator
implmentation and it works, and I kinda understand it, but if someone
has a crisp and constructive methodical derivation from problem
statement, you're very welcome !

(
(lambda (f n) (funcall f f n) )
(lambda (f n) (if (zerop n) 1
(* n (funcall f f (1- n))))
)
5)

However, I picked up this line also and I cant understand it at all as
well as it has something missing, certainly a 5

( (lambda(f) ((lambda (Y) (f (Y Y))) (lambda (Y) (f (Y Y)))))
(lambda (ff n) (if (< n 1) 1 (* n (ff (- n 1))))) )

Hopefully, these may inspire you along the lines, I am having some
vague inspirational thoughts, however, the problem on the top is
rather well defined, to solve it as simply as possible, preferably
carrying the style of the first line.

Swami Tota Ram Shankar