Deutsch   English   Français   Italiano  
<103ebv0$22d39$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: "B. Pym" <Nobody447095@here-nor-there.org>
Newsgroups: comp.lang.lisp
Subject: Re: What's more idiomatic?
Date: Tue, 24 Jun 2025 14:16:15 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 95
Message-ID: <103ebv0$22d39$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Tue, 24 Jun 2025 16:16:16 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="707e9bf545b0798668d5862c799e5553";
	logging-data="2176105"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX180ACCtlGHiariNVCM8Mwdj"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:h+JtPHRqvAKjnX73iIW2o0kajnY=

Pascal Costanza wrote:

> (loop for x in '(1 2 3)
>        for y in '(4 5 6)
>        collect (* 2 (+ x y)))
> 
> vs.
> 
> (mapcar (lambda (x y)
>            (* 2 (+ x y)))
>          '(1 2 3)
>          '(4 5 6))


What if there were 26 lists instead of 2?  Instead of just
"x" and "y", the CL worshipper would have to use "a" through
"z".  Of course, he would run into another problem.
In CL (COBOL-Like), if you try to use "t" as a variable name,
you get:

T is a constant and thus cannot be set.

(loop
  for a in '(0 1 2)
  for b in '(3 4 5)
  for c in '(6 7 8)
  for d in '(9 10 11)
  for e in '(12 13 14)
  for f in '(15 16 17)
  for g in '(18 19 20)
  for h in '(21 22 23)
  for i in '(24 25 26)
  for j in '(27 28 29)
  for k in '(30 31 32)
  for l in '(33 34 35)
  for m in '(36 37 38)
  for n in '(39 40 41)
  for o in '(42 43 44)
  for p in '(45 46 47)
  for q in '(48 49 50)
  for r in '(51 52 53)
  for s in '(54 55 56)
  for t-is-a-constant in '(57 58 59)
  for u in '(60 61 62)
  for v in '(63 64 65)
  for w in '(66 67 68)
  for x in '(69 70 71)
  for y in '(72 73 74)
  for z in '(75 76 77)
  collect (* 2 (+ a b c d e f g h i j k l m n o p q r s
                t-is-a-constant u v w x y z)))

===>
(1950 2002 2054)

Yes, CL (COBOL-Like) is an unbelievably clunky language.
Its worshippers have no affinity for Lispy programming or
for elegance of any sort.

Instead of giving a name to the number from each list,
wouldn't it be easier simply to say "sum the numbers from
the lists"?


(define the-lists
  '((0 1 2)
  (3 4 5)
  (6 7 8)
  (9 10 11)
  (12 13 14)
  (15 16 17)
  (18 19 20)
  (21 22 23)
  (24 25 26)
  (27 28 29)
  (30 31 32)
  (33 34 35)
  (36 37 38)
  (39 40 41)
  (42 43 44)
  (45 46 47)
  (48 49 50)
  (51 52 53)
  (54 55 56)
  (57 58 59)
  (60 61 62)
  (63 64 65)
  (66 67 68)
  (69 70 71)
  (72 73 74)
  (75 76 77)))

(apply map (lambda args (* 2 (apply + args))) the-lists)
===>
(1950 2002 2054)