From: Damien Mattei <damien.mattei@gmail.com>
To: guile-user <guile-user@gnu.org>
Subject: Re: comparator in match pattern
Date: Wed, 28 Jun 2023 22:52:29 +0200 [thread overview]
Message-ID: <CADEOadcrhfTHNe9DhjFafo6eqPQONRAiQwM9KOb8K8GwO3-R5A@mail.gmail.com> (raw)
In-Reply-To: <CADEOadetZEd+V2W9fvxpKiBoPMZSoiRP849Xao=DgCc4XjOdXg@mail.gmail.com>
seems to works now:
scheme@(guile-user)> (match (list 1 /) ((c (? (cut equal? <> /))) 'cool))
$2 = cool
On Wed, Jun 28, 2023 at 9:47 PM Damien Mattei <damien.mattei@gmail.com> wrote:
>
> thank you, ok , i understand ,my Scheme+ redefined <> to not = , this
> was the problem, i apologize
>
> On Wed, Jun 28, 2023 at 5:27 PM Vivien Kraus <vivien@planete-kraus.eu> wrote:
> >
> > 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
prev parent reply other threads:[~2023-06-28 20:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 8:44 comparator in match pattern Damien Mattei
2023-06-28 8:55 ` Vivien Kraus
2023-06-28 13:38 ` Damien Mattei
2023-06-28 13:51 ` Vivien Kraus
2023-06-28 13:55 ` Vivien Kraus
2023-06-28 15:10 ` Damien Mattei
2023-06-28 15:31 ` Vivien Kraus
2023-06-28 19:47 ` Damien Mattei
2023-06-28 20:52 ` Damien Mattei [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADEOadcrhfTHNe9DhjFafo6eqPQONRAiQwM9KOb8K8GwO3-R5A@mail.gmail.com \
--to=damien.mattei@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).