Sujet : Re: the "loop" macro
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lispDate : 30. Jun 2025, 18:27:35
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103uhe6$29ud8$1@dont-email.me>
References : 1
User-Agent : XanaNews/1.18.1.6
B. Pym wrote:
M. Pitman wrote:
(loop with best-foo = nil ;untested
for foo in (list foo1 foo2)
when (or (not best-foo)
(> (weight foo) (weight best-foo)))
do (setq best-foo foo)
finally (return best-foo))
Gauche Scheme:
(use gauche.collection :only (find-max))
(find-max '((a 2) (b 8) (c 5)) :key last)
===>
(b 8)
(use gauche.sequence) ;; size-of
(reduce
(lambda(word best)
(if (> (size-of word) (size-of best)) word best))
#f ;; Returned if list is empty.
'("a" "jut" "by" "cling" "saw"))
===>
"cling"