[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: comparator in match pattern
From: |
Damien Mattei |
Subject: |
Re: comparator in match pattern |
Date: |
Wed, 28 Jun 2023 17:10:52 +0200 |
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
and / is not a variable , it is simply a separator , the / procedure
too,and it is not quoted
in Racket this works:
(match (list container index1-or-keyword index2-or-keyword)
((list c (== /) (== /)) (displayln "T[/ /]"))
i can not find an equivalent in Guile:
(match (list 1 /) ((list c (? (cut equal? <> /))) 'cool))
;;; <stdin>:38:0: warning: wrong number of arguments to `#<tree-il
(lambda () (lambda-case ((() #f #f #f () ()) (call (toplevel equal?)
(toplevel <>) (toplevel /)))))>'
i do not understand the syntax.
i can not use the ther solutions with backquote or quote because the
infix parser give / not '/ to my procedures. I have solutions without
match, using cond but they are more long to code and less readable.
On Wed, Jun 28, 2023 at 3:51 PM Vivien Kraus <vivien@planete-kraus.eu> wrote:
>
> Le mercredi 28 juin 2023 à 15:51 +0200, Vivien Kraus a écrit :
> > So, you want to match against the / symbol, not the value of a
> > variable
> > named /?
>
> Sorry, I misread. You actually have a variable named /.
>
> So this code is the only relevant one:
>
> (use-modules (ice-9 match) (srfi srfi-26))
> (let ((/ 42))
> (match (list 1 42)
> ((c (? (cut equal? <> /)))
> c)))
>
> 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, 2023/06/28
- Re: comparator in match pattern, Vivien Kraus, 2023/06/28
- Re: comparator in match pattern,
Damien Mattei <=
- 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