Re: the "loop" macro

Liste des GroupesRevenir à cl lisp 
Sujet : Re: the "loop" macro
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lisp
Date : 18. Jun 2025, 15:00:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <102ugqf$35mcn$1@dont-email.me>
References : 1 2
User-Agent : XanaNews/1.18.1.6
B. Pym wrote:

B. Pym wrote:
 
 (loop for item in list
       maximize (f item))
 
It's shorter in Gauche Scheme.
 
(use srfi-42)   ;; max-ec
 
(max-ec (: x '(-8 2 0)) (abs x))
  ===>
8
 
 (loop for x in '(1 2 3 4 5 6 7)
    when (evenp x)
     collect x into evens
    else
     collect x into odds
    finally
     (return (values evens odds)))
 => (2 4 6), (1 3 5 7)
 
It's shorter in Gauche Scheme.
 
(partition even? '(2 3 4 5 6 7))
  ===>
(2 4 6)
(3 5 7)



 (loop for x in '(a b (c d) e f)
       when (atom x)
        collect x
       else
        append x)
 => (A B C D E F)

It's shorter in Gauche Scheme.

(append-map
  (lambda (x) (if (pair? x) x (list x)))
  '(a b (c d) e f))
  ===>
(a b c d e f)

Date Sujet#  Auteur
18 Jun 25 * Re: the "loop" macro4B. Pym
18 Jun 25 `* Re: the "loop" macro3B. Pym
18 Jun 25  `* Re: the "loop" macro2B. Pym
30 Jun 25   `- Re: the "loop" macro1B. Pym

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal