From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Subject: bug#36763: `guix search` does unexpected logical and Date: Mon, 16 Sep 2019 10:17:31 +0200 Message-ID: <87h85cejtw.fsf@gnu.org> References: <87imrqrp8t.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:56879) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9mCx-0004OM-Jp for bug-guix@gnu.org; Mon, 16 Sep 2019 04:18:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9mCw-0006Zs-Bn for bug-guix@gnu.org; Mon, 16 Sep 2019 04:18:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40286) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9mCw-0006Zl-8c for bug-guix@gnu.org; Mon, 16 Sep 2019 04:18:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1i9mCw-0004Aa-1T for bug-guix@gnu.org; Mon, 16 Sep 2019 04:18:02 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: (zimoun's message of "Fri, 13 Sep 2019 20:23:50 +0200") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: zimoun Cc: 36763@debbugs.gnu.org Hello! zimoun skribis: > On Thu, 25 Jul 2019 at 19:35, Ludovic Court=C3=A8s wrote: > >> (fold p (make-list =E2=80=A6) metrics) >> >> looks a lot like: >> >> (map (lambda (x) (fold p x metrics)) regexps) >> >> Well, something like that. :-) > > Second try attached with your advice. :-) Neat! > + (let ((scores (map > + (lambda (regexp) > + (fold > + (lambda (metric relevance) > + (match metric > + ((field . weight) > + (match (field obj) > + (#f relevance) > + ((? string? str) > + (+ relevance (* (score str regexp) weight))) > + ((lst ...) > + (+ relevance (* weight > + (apply + (map > + (lambda (str) > + (score str regex= p)) > + lst))))))))) > + 0 metrics)) > + regexps))) For readability, I=E2=80=99d suggest giving a name to one of the two lambdas above, so you can write, say: (map regexp-scores regexps) where: (define (regexp-scores regexp) (fold (lambda (metric relevance) =E2=80=A6) =E2=80=A6)) Also, could you add a couple of tests (such as the =E2=80=9Clibb2=E2=80=9D = example for =E2=80=9Ccrypto=E2=80=9D + =E2=80=9Clibrary=E2=80=9D you mentioned earlier)= ? You can add them to the existing =E2=80=9Cpackage-relevance=E2=80=9D test in tests/ui.scm. Bonus points if you send the patch with =E2=80=98git format-patch=E2=80=99 = and with a commit log: https://guix.gnu.org/manual/en/html_node/Submitting-Patches.html Thank you! Ludo=E2=80=99.