Sujet : Re: Why don't people like lisp?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.lispDate : 04. Jul 2024, 08:57:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240703234106.863@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-07-04, Jeff Barnett <
jbb@notatt.com> wrote:
I believe that (max) and (min) would work just fine in CL if including
the IEEE infinities was required to be conforming. Without them or
something similar, it would be hard to make a sensible definition.
>
Also refresh my memory: doesn't CL define a map-like function that looks
like (MAP! binary-op list identity-element) so that:
(MAP! #'+ list 0) is the sum of the elements in the list
(MAP! #'* list 10 is the product of the elements in list
(MAP! #'max list -oo) is the max element in the list
(MAP! #'min list +oo) is the minimum element in the list
(MAP! #'append list nil) is the list made by appending the sublists
of list
etc.
In all of these if the list argument is nil, the result is the identity
element.
(reduce #'+ list :initial-value 0)
- If :initial-value is present it's as if it is prepended to the list.
- When the effective list (main input plus any initial value)
contains only one element, that element is returned without the
function being called.
- When the effective list is empty (main input is empty and no
initial value is specified), reduce calls the function with
no arguments to obtain the identity element, which is returned.
This obviously works for + and *.
- :from-end t can be used to obtain a right reduction.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca