From mboxrd@z Thu Jan 1 00:00:00 1970 From: swedebugia Subject: Re: Learning the match-syntax... Date: Mon, 7 Jan 2019 18:34:20 +0100 Message-ID: <9ee2cc12-7394-6256-7268-adc43c1a56c9@riseup.net> References: <87pntxwqx0.fsf@gnu.org> <08635A1A-EDA5-44B0-8C8A-532F16683154@flashner.co.il> <20181219192926.GB2581@macbook41> <87imzmmwno.fsf@gnu.org> <20181225143202.GO2581@macbook41> <87zhsf2ec6.fsf@gnu.org> <878szx1nah.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([209.51.188.92]:39929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggYgf-0005Wi-Gk for guix-devel@gnu.org; Mon, 07 Jan 2019 12:27:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggYgd-0005Wk-8x for guix-devel@gnu.org; Mon, 07 Jan 2019 12:27:41 -0500 In-Reply-To: <878szx1nah.fsf@gmail.com> Content-Language: en-US List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Chris Marusich Cc: "guix-devel@gnu.org" , Guix-devel 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