all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: zimoun <zimon.toutoune@gmail.com>
Cc: 36763@debbugs.gnu.org
Subject: bug#36763: `guix search` does unexpected logical and
Date: Mon, 16 Sep 2019 10:17:31 +0200	[thread overview]
Message-ID: <87h85cejtw.fsf@gnu.org> (raw)
In-Reply-To: <CAJ3okZ0UOVg=gV4Ckx0QSC3Qsx_ix3J0V7kJ5zew9TSax=bF+g@mail.gmail.com> (zimoun's message of "Fri, 13 Sep 2019 20:23:50 +0200")

Hello!

zimoun <zimon.toutoune@gmail.com> skribis:

> On Thu, 25 Jul 2019 at 19:35, Ludovic Courtès <ludo@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’.

  reply	other threads:[~2019-09-16  8:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-22 17:11 bug#36763: `guix search` does unexpected logical and zimoun
2019-07-25 17:35 ` Ludovic Courtès
2019-09-13 18:23   ` zimoun
2019-09-16  8:17     ` Ludovic Courtès [this message]
2019-09-19 17:32       ` zimoun
2019-09-19 19:56         ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h85cejtw.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=36763@debbugs.gnu.org \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.