Hej :)

On 2019-01-06 22:36, Chris Marusich wrote:
swedebu...@riseup.net writes:

I'm trying very hard to learn the guile match-syntax.

When I first learned about "match", I found the Guile documentation to
be insufficient.  It is good as a reference, though.

I recommend looking beyond the Guile reference manual for a tutorial.
Check the Guile source for "match" related things.

Good idea.

Also, look at
introductions to "match" from other Schemes, such as Racket.  I think
you will understand it better by doing that.


Thanks I already did that actually. The Racket guide was way better but not enough. Now I finally crossed the threshold to partially understanding it.

e.g.
(match '(1 2 "y" "x")
  (1
   'one)
  (number
   'number))

Will match any number for the first clause and any string for the second. It ONLY checks if it is a number.

To actually match something e.g. the "x" literally we need to nest the match like this:

(match '(1 2 y x)
  (string
   (match string
        ("x"
          'x!)))
  (number
   'number))

Positional arguments work like this:

(match '(1 2 y x)
  ;match the third item
  (_ _ string
   ;check if it is the literal "x"
   (match string
        ("x"
          'x!)))
  (number
   'number))

Correct?

--
Cheers Swedebugia

Reply via email to