[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#39599] [PATCH 1/4] build-system: Add copy-build-system.
From: |
Ricardo Wurmus |
Subject: |
[bug#39599] [PATCH 1/4] build-system: Add copy-build-system. |
Date: |
Thu, 20 Feb 2020 10:47:10 +0100 |
User-agent: |
mu4e 1.2.0; emacs 26.3 |
Pierre Neidhardt <address@hidden> 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
- [bug#39599] [PATCH 0/2] New build system: copy-build-system, Pierre Neidhardt, 2020/02/14
- [bug#39599] [PATCH 1/2] build-system: Add copy-build-system., Pierre Neidhardt, 2020/02/14
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Pierre Neidhardt, 2020/02/17
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Alex Griffin, 2020/02/19
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Pierre Neidhardt, 2020/02/20
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Mathieu Othacehe, 2020/02/20
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Pierre Neidhardt, 2020/02/20
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Julien Lepiller, 2020/02/20
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Pierre Neidhardt, 2020/02/20
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Pierre Neidhardt, 2020/02/21
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Nicolas Goaziou, 2020/02/21
- [bug#39599] [PATCH 1/4] build-system: Add copy-build-system., Pierre Neidhardt, 2020/02/21