[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: comparator in match pattern
From: |
Vivien Kraus |
Subject: |
Re: comparator in match pattern |
Date: |
Wed, 28 Jun 2023 15:51:48 +0200 |
User-agent: |
Evolution 3.46.4 |
Le mercredi 28 juin 2023 à 15:38 +0200, Damien Mattei a écrit :
> scheme@(guile-user)> (use-modules (ice-9 match))
> scheme@(guile-user)> (match (list 1 /) ((list c (cut equal? <> /))
So, you want to match against the / symbol, not the value of a variable
named /?
The simplest case would be to use quasiquote/unquote syntax in the
pattern:
(match (list 1 '/)
(`(,c /)
c))
should give: 1, the value of c
If you don’t understand quasiquote/unquote, you can use the slightly
uglier:
(match (list 1 '/)
((c '/)
c))
If / is the name of a variable (why not), you can do:
(use-modules (srfi srfi-26))
(let ((/ 42))
(match (list 1 42)
((c (? (cut equal? <> /)))
c)))
In any case, no need to write "list" in the pattern.
Vivien
- comparator in match pattern, Damien Mattei, 2023/06/28
- Re: comparator in match pattern, Vivien Kraus, 2023/06/28
- Re: comparator in match pattern, Damien Mattei, 2023/06/28
- Re: comparator in match pattern,
Vivien Kraus <=
- Re: comparator in match pattern, Vivien Kraus, 2023/06/28
- Re: comparator in match pattern, Damien Mattei, 2023/06/28
- Re: comparator in match pattern, Vivien Kraus, 2023/06/28
- Re: comparator in match pattern, Damien Mattei, 2023/06/28
- Re: comparator in match pattern, Damien Mattei, 2023/06/28