unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* comparator in match pattern
@ 2023-06-28  8:44 Damien Mattei
  2023-06-28  8:55 ` Vivien Kraus
  0 siblings, 1 reply; 9+ messages in thread
From: Damien Mattei @ 2023-06-28  8:44 UTC (permalink / raw)
  To: guile-user

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-06-28 20:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).