Clojure

Add zero-arity versions of every-pred and some-fn

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Triaged

Description

Zero-arity versions of these fns are useful in situations like the following:

;; compute-preds-for may return zero or many predicate fns
(let [preds (compute-preds-for something)]
  (filter (apply every-pred preds) some-coll))

Approach: This patch adds zero-arity versions of every-pred and some-fn with these semantics:

(every-pred) === (constantly true)
(some-fn)    === (constantly nil)

Patch: 0001-Add-zero-arity-variants-for-every-pred-and-some-fn.patch

  • Patch adds zero-arity version
  • Patch reformats docstring to 80 character width (matching other core fns) - comments are identical other than the addition of a final sentence stating behavior with zero-arity.

Screened by:

Activity

Alex Miller made changes -
Field Original Value New Value
Labels patch test
Alex Miller made changes -
Approval Triaged [ 10120 ]
Tassilo Horn made changes -
Tassilo Horn made changes -
Attachment 0001-Add-zero-arity-variants-for-every-pred-and-some-fn.patch [ 11611 ]
Alex Miller made changes -
Description This patch adds zero-arity versions of every-pred and some-fn with these semantics.

{noformat}
(every-pred) === (constantly true)
(some-fn) === (constantly nil)
{noformat}

These variants are useful in situations like the following:

{noformat}
;; compute-preds-for may return zero or many predicate fns
(let [preds (compute-preds-for something)]
  (filter (apply every-pred preds) some-coll))
{noformat}
Zero-arity versions of these fns are useful in situations like the following:

{noformat}
;; compute-preds-for may return zero or many predicate fns
(let [preds (compute-preds-for something)]
  (filter (apply every-pred preds) some-coll))
{noformat}

*Approach:* This patch adds zero-arity versions of every-pred and some-fn with these semantics:

{noformat}
(every-pred) === (constantly true)
(some-fn) === (constantly nil)
{noformat}

*Patch:* 0001-Add-zero-arity-variants-for-every-pred-and-some-fn.patch
- Patch adds zero-arity version
- Patch reformats docstring to 80 character width (matching other core fns) - comments are identical other than the addition of a final sentence stating behavior with zero-arity.

*Screened by:*
Summary Zero-arity versions of every-pred and some-fn Add zero-arity versions of every-pred and some-fn

People

Vote (2)
Watch (1)

Dates

  • Created:
    Updated: