guile-user
[Top][All Lists]
Advanced

[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 15:38:44 +0200

hello
i do not understand how i can do that with match:

scheme@(guile-user)> (use-modules (ice-9 match))
scheme@(guile-user)> (match (list 1 /) ((list c (cut equal? <> /))
'cool) ((list c t) 'not_cool))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern"
(1 #<procedure / (#:optional _ _ . _)>))'.

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,q
scheme@(guile-user)> (match (list 1 /) ((? (cut equal? <> /)) 'cool)
((list c t) 'not_cool))
;;; <stdin>:23:0: warning: wrong number of arguments to `#<tree-il
(lambda () (lambda-case ((() #f #f #f () ()) (call (toplevel equal?)
(toplevel <>) (toplevel /)))))>'
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Wrong number of arguments to (1 #<procedure / (#:optional _ _ . _)>)

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.


On Wed, Jun 28, 2023 at 10:52 AM Vivien Kraus <vivien@planete-kraus.eu> wrote:
>
> Hello!
>
> Le mercredi 28 juin 2023 à 10:44 +0200, Damien Mattei a écrit :
> > does it exists in Guile something like == in Racket,
> > documented here:
> > https://docs.racket-lang.org/reference/match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._~3d~3d%29%29
>
> From what I understand, (== something) would be translated as (? (cut
> equal? <> something)) if you import srfi-26 for cut (or cute, if
> something needs to be evaluated once).
>
> Vivien



reply via email to

[Prev in Thread] Current Thread [Next in Thread]