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:36:07 -0500 Message-ID: <0E59A965-E036-4CF6-BF7E-C23822A01DCD@vany.ca> References: <6608cd4f-b96a-c8cb-4cc6-d3c0bb080f94@riseup.net> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----EL7J6D2BPBHKLBI8VNR8HOU9LN0BCP" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSixs-00059U-2s for guix-devel@gnu.org; Fri, 30 Nov 2018 08:36:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSixo-0001xt-4L for guix-devel@gnu.org; Fri, 30 Nov 2018 08:36:16 -0500 Received: from mail2.vany.ca ([142.54.190.254]:42774) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gSixn-0001xj-Sm for guix-devel@gnu.org; Fri, 30 Nov 2018 08:36:12 -0500 In-Reply-To: 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 ------EL7J6D2BPBHKLBI8VNR8HOU9LN0BCP Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Just saw Ricardo's message=2E Sorry for the redundancy! On November 30, 2018 8:34:46 AM EST, Adam Van Ymeren wrot= e: >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 macr= o >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 > >>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 ------EL7J6D2BPBHKLBI8VNR8HOU9LN0BCP Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Just saw Ricardo's message=2E Sorry for the redund= ancy!

On November 30, 2018 8:34:46 AM EST= , Adam Van Ymeren <adam@vany=2Eca> wrote:
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)

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


On= November 29, 2018 6:13:26 PM EST, swedebugia <swedebugia@riseup=2Enet&g= t; 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?
------EL7J6D2BPBHKLBI8VNR8HOU9LN0BCP--