[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#36763: `guix search` does unexpected logical and
From: |
Ludovic Courtès |
Subject: |
bug#36763: `guix search` does unexpected logical and |
Date: |
Mon, 16 Sep 2019 10:17:31 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Hello!
zimoun <address@hidden> skribis:
> On Thu, 25 Jul 2019 at 19:35, Ludovic Courtès <address@hidden> wrote:
>
>> (fold p (make-list …) 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 regexp))
> + lst)))))))))
> + 0 metrics))
> + regexps)))
For readability, I’d 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)
…)
…))
Also, could you add a couple of tests (such as the “libb2” example for
“crypto” + “library” you mentioned earlier)? You can add them to the
existing “package-relevance” test in tests/ui.scm.
Bonus points if you send the patch with ‘git format-patch’ and with a
commit log:
https://guix.gnu.org/manual/en/html_node/Submitting-Patches.html
Thank you!
Ludo’.