bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24014: 24.5; doc string of `cl-reduce'


From: Clément Pit--Claudel
Subject: bug#24014: 24.5; doc string of `cl-reduce'
Date: Mon, 18 Jul 2016 18:03:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

On 2016-07-18 16:02, Drew Adams wrote:
>>> Even providing a functional-programming definition of `reduce' is
>>> better than just describing it in abstract terms, if we can't come
>>> up with a more down-to-earth description.
>>
>> What about adding a few examples? Something like this maybe?
>>
>>     (cl-reduce f '(1 2 3 4 5))
>>       ↔ (f (f (f (f 1 2) 3) 4) 5)
>>
>>     (cl-reduce f '(1 2 3 4 5) :initial-value 0)
>>       ↔ (f (f (f (f (f 0 1) 2) 3) 4) 5)
>>
>>     (cl-reduce f '(1 2 3 4 5) :from-end t)
>>       ↔ (f 1 (f 2 (f 3 (f 4 5))))
>>
>>     (cl-reduce f '(1 2 3 4 5) :from-end t :initial-value 0)
>>       ↔ (f 1 (f 2 (f 3 (f 4 (f 5 0)))))
> 
> LGTM - except that f should be quoted as an arg to `cl-reduce'.
> E.g. (cl-reduce 'f '(1 2 3)).
> 
> And a shorter list makes things a tiny bit simpler: (1 2 3).
> 
> (And I'm not crazy about the too-short double arrow, personally.)

I wasn't sure about the sort list; I actually found things more confusing that 
way.  Should this go in the ELisp manual, or in the docstring?
No strong feelings about the double arrow, and fine with me for quoting f.

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]