From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: Help with map match Date: Fri, 30 Nov 2018 03:45:17 +0100 Message-ID: <87ftvj2shu.fsf@elephly.net> References: <6608cd4f-b96a-c8cb-4cc6-d3c0bb080f94@riseup.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSYoH-0007Ps-JC for guix-devel@gnu.org; Thu, 29 Nov 2018 21:45:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSYoE-0005gl-AS for guix-devel@gnu.org; Thu, 29 Nov 2018 21:45:41 -0500 Received: from sender-of-o52.zoho.com ([135.84.80.217]:21405) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gSYoD-0005gL-VW for guix-devel@gnu.org; Thu, 29 Nov 2018 21:45:38 -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: swedebugia Cc: guix-devel Hi, > 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.g. "rollup-plugin" should match > "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) =E2=80=9Cmap=E2=80=9D requires a procedure and a list as its arguments, app= lies the procedure to every element and then returns a new list with the results. Since you just want a single boolean as the return value you may want to use =E2=80=9Cany=E2=80=9D instead, which tells you if a procedure returned = #t for =E2=80=9Cany=E2=80=9D of the items in a list. --8<---------------cut here---------------start------------->8--- (use-modules (srfi srfi-1)) (define (blacklisted? pkg-name) (string-prefix? "rollup-" pkg-name)) (any blacklisted? '("rollup-plugin" "rollup-plugin-foo")) ; =3D> #t (any blacklisted? '("all" "is" "good")) ; =3D> #f --8<---------------cut here---------------end--------------->8--- =E2=80=9Cblacklisted?=E2=80=9D can then implement whatever logic you need. -- Ricardo