(some-fn p)
(some-fn p1 p2)
(some-fn p1 p2 p3)
(some-fn p1 p2 p3 & ps)
Takes a set of predicates and returns a function f that returns the first logical true value
returned by one of its composing predicates against any of its arguments, else it returns
logical false. Note that f is short-circuiting in that it will stop execution on the first
argument that triggers a logical true result against the original predicates.
Source
(defn
some-fn
"Takes a set of predicates and returns a function f that returns the first logical true value\n returned by one of its composing predicates against any of its arguments, else it returns\n logical false. Note that f is short-circuiting in that it will stop execution on the first\n argument that triggers a logical true result against the original predicates."
([p]
(fn
sp1
([] nil)
([x] (p x))
([x y] (or (p x) (p y)))
([x y z] (or (p x) (p y) (p z)))
([x y z & args] (or (sp1 x y z) (some p args)))))
([p1 p2]
(fn
sp2
([] nil)
([x] (or (p1 x) (p2 x)))
([x y] (or (p1 x) (p1 y) (p2 x) (p2 y)))
([x y z] (or (p1 x) (p1 y) (p1 z) (p2 x) (p2 y) (p2 z)))
([x y z & args]
(or
(sp2 x y z)
(some
(fn* [p1__18655#] (or (p1 p1__18655#) (p2 p1__18655#)))
args)))))
([p1 p2 p3]
(fn
sp3
([] nil)
([x] (or (p1 x) (p2 x) (p3 x)))
([x y] (or (p1 x) (p2 x) (p3 x) (p1 y) (p2 y) (p3 y)))
([x y z]
(or
(p1 x)
(p2 x)
(p3 x)
(p1 y)
(p2 y)
(p3 y)
(p1 z)
(p2 z)
(p3 z)))
([x y z & args]
(or
(sp3 x y z)
(some
(fn*
[p1__18656#]
(or (p1 p1__18656#) (p2 p1__18656#) (p3 p1__18656#)))
args)))))
([p1 p2 p3 & ps]
(let
[ps (list* p1 p2 p3 ps)]
(fn
spn
([] nil)
([x] (some (fn* [p1__18657#] (p1__18657# x)) ps))
([x y]
(some (fn* [p1__18658#] (or (p1__18658# x) (p1__18658# y))) ps))
([x y z]
(some
(fn*
[p1__18659#]
(or (p1__18659# x) (p1__18659# y) (p1__18659# z)))
ps))
([x y z & args]
(or
(spn x y z)
(some (fn* [p1__18660#] (some p1__18660# args)) ps)))))))