From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adam Van Ymeren Subject: Re: Help with map match Date: Fri, 30 Nov 2018 08:34:46 -0500 Message-ID: References: <6608cd4f-b96a-c8cb-4cc6-d3c0bb080f94@riseup.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----8RAGDC5WAJUMBAF91YDE9W5GWBU6H3" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSiwb-0004V9-CR for guix-devel@gnu.org; Fri, 30 Nov 2018 08:34:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSiwX-0001Cl-EZ for guix-devel@gnu.org; Fri, 30 Nov 2018 08:34:57 -0500 Received: from mail2.vany.ca ([142.54.190.254]:42760) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gSiwX-0001CW-86 for guix-devel@gnu.org; Fri, 30 Nov 2018 08:34:53 -0500 In-Reply-To: <6608cd4f-b96a-c8cb-4cc6-d3c0bb080f94@riseup.net> 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: guix-devel@gnu.org, swedebugia guix-devel ------8RAGDC5WAJUMBAF91YDE9W5GWBU6H3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I believe match is a macro but you need to pass map a lambda=2E Try (map (lambda (a) (match a ("test" #t) =2E=2E=2E) x)=20 Or (map (match-lambda ("test" #t) =2E=2E=2E) x) as match-lambda is a macro= that expands to (lambda (a) (match a =2E=2E=2E)) On November 29, 2018 6:13:26 PM EST, swedebugia = wrote: >Hi > >I'm trying to learn how to check in guile if a node package matches one > >of the items in my blacklist=2E > >First version was with (member pkg-name blacklist) and it worked but=20 >forces me to write down all the blacklisted packages which is tedious=20 >when I can just regex match if it begins with the same name=2E > >Now i'm trying to do the same with match and I could not find any=20 >examples or guides on the subject that I understood=2E :-/ > >blacklist >$1 =3D ("matcha" "webpack" "rollup-plugin-node-resolve" "browserify"=20 >"electron" "statsd" "vega" "grunt-release" "lineman" "lineman-angular") > >I want the procedure to return #t if a match is found and I want it to=20 >match if it begins with the same e=2Eg=2E "rollup-plugin" should match=20 >"rollup-plugin-node-resolve" and return #t >Else #f > >This did not work: >(use-modules (ice-9 match)) > >(define x > '("ts" "test")) >(map (match x > ("test") #t) > (else #f) x) > >Any ideas? >--=20 >Cheers >Swedebugia ------8RAGDC5WAJUMBAF91YDE9W5GWBU6H3 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable I believe match is a macro but you need to pass ma= p a lambda=2E

Try (map (lambda (a) (match a ("test" #t) =2E=2E=2E) x= )

Or (map (match-lambda ("test" #t) =2E=2E=2E) x) as match-lambda i= s a macro that expands to (lambda (a) (match a =2E=2E=2E))


On November 29, 2018 6:13:26 PM EST, swedebugia <s= wedebugia@riseup=2Enet> wrote:
Hi

I'm trying to learn how to check in guile = if a node package matches one
of the items in my blacklist=2E

Fi= rst version was with (member pkg-name blacklist) and it worked but
forc= es me to write down all the blacklisted packages which is tedious
when = I can just regex match if it begins with the same name=2E

Now i'm tr= ying to do the same with match and I could not find any
examples or gui= des on the subject that I understood=2E :-/

blacklist
$1 =3D ("ma= tcha" "webpack" "rollup-plugin-node-resolve" "browserify"
"electron" "s= tatsd" "vega" "grunt-release" "lineman" "lineman-angular")

I want th= e procedure to return #t if a match is found and I want it to
match if = it begins with the same e=2Eg=2E "rollup-plugin" should match
"rollup-p= lugin-node-resolve" and return #t
Else #f

This did not work:
(= use-modules (ice-9 match))

(define x
'("ts" "test"))
= (map (match x
("test") #t)
(else #f) x)

Any = ideas?
------8RAGDC5WAJUMBAF91YDE9W5GWBU6H3--