all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Pierre Neidhardt <mail@ambrevar.xyz>
Cc: 39599@debbugs.gnu.org
Subject: [bug#39599] [PATCH 1/4] build-system: Add copy-build-system.
Date: Thu, 20 Feb 2020 10:47:10 +0100	[thread overview]
Message-ID: <87ftf5lhep.fsf@elephly.net> (raw)
In-Reply-To: <20200217111228.23716-1-mail@ambrevar.xyz>


Pierre Neidhardt <mail@ambrevar.xyz> writes:

> +  (define* (make-file-predicate matches matches-regexp #:optional (default-value #t))
> +    (if (or matches matches-regexp)
> +        (lambda (file)
> +          (any (lambda (pred) (pred file))
> +               (append
> +                (map (lambda (str)
> +                       (lambda (f) (string-suffix? str f)))
> +                     (or matches '()))
> +                (map (lambda (regexp)
> +                       (lambda (f) (regexp-exec (make-regexp regexp) f)))
> +                     (or matches-regexp '())))))
> +        (const default-value)))

This looks too complicated.

I think this is clearer:

--8<---------------cut here---------------start------------->8---
(define* (make-file-predicate suffixes matches-regexp #:optional (default-value #t))
  (if (or suffixes matches-regexp)
      (let* ((suffixes (or suffixes '()))
             (regexps (map make-regexp (or matches-regexp '())))
             (predicates (append
                          (map (lambda (str)
                                 (cut string-suffix? str <>))
                               suffixes)
                          (map (lambda (regexp)
                                 (cut regexp-exec regexp <>))
                               regexps))))
        (lambda (file)
          (any (cut <> file) predicates)))
      (const default-value)))
--8<---------------cut here---------------end--------------->8---

Also, as Mathieu wrote, please don’t use SET!.

-- 
Ricardo

  parent reply	other threads:[~2020-02-20  9:48 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-14 12:51 [bug#39599] [PATCH 0/2] New build system: copy-build-system Pierre Neidhardt
2020-02-14 12:53 ` [bug#39599] [PATCH 1/2] build-system: Add copy-build-system Pierre Neidhardt
2020-02-14 12:53   ` [bug#39599] [PATCH 2/2] gnu: gcide: Use the copy-build-system Pierre Neidhardt
2020-02-14 13:39   ` [bug#39599] [PATCH 1/2] build-system: Add copy-build-system Giovanni Biscuolo
2020-02-16 13:16     ` Pierre Neidhardt
2020-02-17 11:12 ` [bug#39599] [PATCH 1/4] " Pierre Neidhardt
2020-02-17 11:12   ` [bug#39599] [PATCH 2/4] gnu: gcide: Use the copy-build-system Pierre Neidhardt
2020-02-17 11:12   ` [bug#39599] [PATCH 3/4] gnu: Add clojure-wrapper Pierre Neidhardt
2020-02-17 11:12   ` [bug#39599] [PATCH 4/4] gnu: net-base: Use copy build system Pierre Neidhardt
2020-02-17 11:48   ` [bug#39599] [PATCH 1/4] build-system: Add copy-build-system Mathieu Othacehe
2020-02-20  9:47   ` Ricardo Wurmus [this message]
2020-02-20 10:00     ` Pierre Neidhardt
2020-02-20  1:06 ` Alex Griffin
2020-02-20  8:40   ` Pierre Neidhardt
2020-02-20  8:44     ` Mathieu Othacehe
2020-02-20 15:41     ` Pierre Neidhardt
2020-02-20 17:09       ` [bug#39599] " Julien Lepiller
2020-02-20 18:00         ` Pierre Neidhardt
2020-02-21  9:53           ` Pierre Neidhardt
2020-02-21 10:43             ` Nicolas Goaziou
2020-02-21 11:07               ` Pierre Neidhardt
2020-02-21 11:43                 ` Nicolas Goaziou
2020-02-21 12:04                   ` Pierre Neidhardt
2020-02-21 11:50               ` Tobias Geerinckx-Rice via Guix-patches via
2020-02-21 12:06                 ` Pierre Neidhardt
2020-02-21  3:37   ` [bug#39599] Jack Hill
2020-02-21  3:37     ` [bug#39599] [PATCH v2] gnu: Add gnome-shell-extension-paperwm Jack Hill
2020-02-21 14:34       ` Alex Griffin
2020-02-21 16:22         ` Jack Hill
2020-02-21 18:48           ` Alex Griffin
2020-02-21 18:51             ` Jack Hill

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=87ftf5lhep.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=39599@debbugs.gnu.org \
    --cc=mail@ambrevar.xyz \
    /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.