[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cond*
From: |
Ihor Radchenko |
Subject: |
Re: cond* |
Date: |
Mon, 08 Jan 2024 15:13:10 +0000 |
Richard Stallman <rms@gnu.org> writes:
> > >From my reading of your latest spec of the cond*, I feel that it is
> > getting closer and closer to the features provided by `pcase'. The
> > description is also getting closer to pcase manual page length.
>
> After eliminating the nested constrained variables, it is only 213 lines.
>
> Are there any pcase features that cond* does not provide an equivalent
> for?
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"
In the above, we first match `(,x ,y ,z) against '(1 2 3) and then
match (and sum (guard (< 2 sum))) against the result of (yant/list-sum '(1 2 3))
Also, `pcase' performs some compiler-like optimizations on the provided
patterns.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
- RE: [External] : Re: cond*, (continued)
- RE: [External] : Re: cond*, Drew Adams, 2024/01/08
- 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 <=
- Re: cond*, Richard Stallman, 2024/01/26
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