GNU bug report logs -
#36763
`guix search` does unexpected logical and
Previous Next
Reported by: zimoun <zimon.toutoune <at> gmail.com>
Date: Mon, 22 Jul 2019 17:13:02 UTC
Severity: normal
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hello!
zimoun <zimon.toutoune <at> gmail.com> skribis:
> On Thu, 25 Jul 2019 at 19:35, Ludovic Courtès <ludo <at> gnu.org> 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’.
This bug report was last modified 5 years and 240 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.