> An even more "cute" solution would be if we could avoid the parameter
> argument completely.
>
> The natural way for this in PicoLisp is the implied parameter '@'.
>
> We might define
>
>    (de map@ "Args"
>       (mapcar
>          '(("E") (and "E" (run (cdr "Args"))))  # 'and' sets '@'
>          (eval (car "Args")) ) )
>
> With that, you can call
>
>    : (map@ (1 2 3) (* @ @))
>    -> (1 4 9)
>

I love this! And you're right, it's even more cute. That's a really clever
use of 'and'. Is that fairly common in PicoLisp code? I guess I always
figured 'and' would be used with more "important" expressions, if you will.
For example, (and (do-really-long-and-complex-things X) ...), so we can
save ourselves some typing with '@' bound to the result of doing long and
complex things to X. But here 'and' is used to simply to check that there
is another element to map over and save it's value. Which is, I guess, the
same concept: evaluate an expression, save the result for later reference.
Ok, thanks for bearing with me as I talk myself through this :)

Reply via email to