[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 17:31:40 +0200 |
User-agent: |
Evolution 3.46.4 |
Le mercredi 28 juin 2023 à 17:10 +0200, Damien Mattei a écrit :
> Vivien , your solution is not working:
>
> (let ((/ 42))
> (match (list 1 42)
> ((c (? (cut equal? <> /)))
> c)))
> ;;; <stdin>:30:2: warning: wrong number of arguments to `#<tree-il
> (lambda () (lambda-case ((() #f #f #f () ()) (call (toplevel equal?)
> (toplevel <>) (lexical / /-1dff1b83541ce327-407)))))>'
> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
> Wrong number of arguments to 42
It works on my side (see screenshot). You did not quote the module
import line in your reply, did you forget to paste it?
(use-modules (ice-9 match) (srfi srfi-26))
Otherwise it is likely a problem with your guile installation, and I
can’t really help.
> and / is not a variable , it is simply a separator , the / procedure
> too,and it is not quoted
I do not understand. Do you want to match against the '/ symbol or the
variable/procedure bound to "/"?
If you want to match against something that is bound to "/", then the
cut-equal solution is relevant. If you want to match against the /
symbol, then you can do either one of these:
(use-modules (ice-9 match))
(match (list 1 '/)
(`(,c /)
c))
or
(use-modules (ice-9 match))
(match (list 1 '/)
((c '/)
c))
> in Racket this works:
>
> (match (list container index1-or-keyword index2-or-keyword)
>
> ((list c (== /) (== /)) (displayln "T[/ /]"))
This is not a self-contained example, I don’t know what is index*-or-
keyword. Is it the division function or whatever is bound to / at that
time? The / symbol?
Vivien
png_jV20adyR5.png
Description: PNG image
- 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, 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, Damien Mattei, 2023/06/28
- Re: comparator in match pattern, Damien Mattei, 2023/06/28