From: swedebugia <swedebugia@riseup.net>
To: Chris Marusich <cmmarusich@gmail.com>
Cc: "guix-devel@gnu.org" <guix-devel@gnu.org>,
Guix-devel <guix-devel-bounces+swedebugia=riseup.net@gnu.org>
Subject: Re: Learning the match-syntax...
Date: Mon, 7 Jan 2019 18:34:20 +0100 [thread overview]
Message-ID: <9ee2cc12-7394-6256-7268-adc43c1a56c9@riseup.net> (raw)
In-Reply-To: <878szx1nah.fsf@gmail.com>
Hej :)
On 2019-01-06 22:36, Chris Marusich wrote:
> swedebugia@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
next prev parent reply other threads:[~2019-01-07 17:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 20:45 `guix lint' warn of GitHub autogenerated source tarballs Arun Isaac
2018-12-19 8:43 ` Pierre Neidhardt
2018-12-19 14:07 ` Ludovic Courtès
2018-12-19 14:33 ` Efraim Flashner
2018-12-19 17:43 ` Arun Isaac
2018-12-19 19:29 ` Efraim Flashner
2018-12-21 20:50 ` Ludovic Courtès
2018-12-21 21:00 ` swedebugia
2018-12-25 14:32 ` Efraim Flashner
2019-01-05 17:39 ` Ludovic Courtès
2019-01-05 21:25 ` Learning the match-syntax swedebugia
2019-01-05 22:35 ` Ricardo Wurmus
2019-01-06 21:36 ` Chris Marusich
2019-01-07 17:34 ` swedebugia [this message]
2019-01-07 22:18 ` Ricardo Wurmus
2019-01-08 8:25 ` swedebugia
2019-01-08 20:32 ` Ricardo Wurmus
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9ee2cc12-7394-6256-7268-adc43c1a56c9@riseup.net \
--to=swedebugia@riseup.net \
--cc=cmmarusich@gmail.com \
--cc=guix-devel-bounces+swedebugia=riseup.net@gnu.org \
--cc=guix-devel@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.