[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cond*
From: |
Richard Stallman |
Subject: |
Re: cond* |
Date: |
Fri, 26 Jan 2024 22:37:45 -0500 |
[[[ To any NSA and FBI agents reading my email: please consider ]]]
[[[ whether defending the US Constitution against all enemies, ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]
> Other than rx, one missing feature is an ability to match against
> multiple values in a single condition:
> (defun yant/list-sum (list)
> (apply #'+ list))
> (pcase '(1 2 3)
> ((and `(,x ,y ,z) (app yant/list-sum (and sum (guard (< 2 sum)))))
> (format "%d + %d + %d = %d; 2 is < %d" x y z sum sum)))
> ; => "1 + 2 + 3 = 6; 2 is < 6"
Understanding this was a struggle, but I think it can be done with
(cond* ((match* `(,x ,y ,z) list-of-three))
((< 2 (+ x y z))
success)))
It is not the one condition which is the goal you specified, but given
the flexibility of cond* it doesn't need to be one condition. And it
is much clearer than the pcase code to do the same job.
--
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)
- map seq and radix-tree-leaf, in pcase, (continued)
- map seq and radix-tree-leaf, in pcase, Richard Stallman, 2024/01/08
- Re: cond*, Richard Stallman, 2024/01/07
- Re: cond*, Ihor Radchenko, 2024/01/10
- Re: cond*, Richard Stallman, 2024/01/12
- Re: cond*, Adam Porter, 2024/01/13
- Re: cond*, Richard Stallman, 2024/01/15
- Re: cond*, Ihor Radchenko, 2024/01/13
- Re: cond*, Richard Stallman, 2024/01/14
- Re: cond*, Richard Stallman, 2024/01/07
- Re: cond*, Ihor Radchenko, 2024/01/08
- Re: cond*,
Richard Stallman <=
Re: cond*, Richard Stallman, 2024/01/02
- Re: cond*, Ihor Radchenko, 2024/01/03
- Re: cond*, Richard Stallman, 2024/01/05
- Re: cond*, Ihor Radchenko, 2024/01/06
- Re: cond*, Richard Stallman, 2024/01/07
- Re: cond*, Ihor Radchenko, 2024/01/08
- Re: cond*, Richard Stallman, 2024/01/26
Re: cond*, Richard Stallman, 2024/01/02