From: Damien Mattei <damien.mattei@gmail.com>
To: guile-user <guile-user@gnu.org>
Subject: comparator in match pattern
Date: Wed, 28 Jun 2023 10:44:03 +0200 [thread overview]
Message-ID: <CADEOadf3rLs_ywL_8jEYu0in5D7Vduiacq1LFdqOVp2a_4EhAA@mail.gmail.com> (raw)
hello
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
that allows some code like that:
(match (list container index1-or-keyword index2-or-keyword)
((list c (== /) (== /)) (displayln "T[/ /]"))
((list c i1 (== /)) (displayln "T[i1 /]"))
((list c (== /) i2) (displayln "T[/ i2]"))
((list c i1 i2) (let ((value expr)) ;; to avoid compute it twice
;; normal case
(if (vector? c)
(function-array-n-dim-set! c value (reverse (list
i1 i2))) ;;(array-n-dim-set! array value i1 i2)
(array-set! c i1 i2 value))
value)))
Regards,
Damien
next reply other threads:[~2023-06-28 8:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 8:44 Damien Mattei [this message]
2023-06-28 8:55 ` comparator in match pattern 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
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=CADEOadf3rLs_ywL_8jEYu0in5D7Vduiacq1LFdqOVp2a_4EhAA@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).