In the past when I’ve “needed” this (you never really need this though, do you…) I implemented \vee and \wedge like the Base implementation of ∘
"""
f ∧ g ∧ ...
Create an anonymous function that evaluates to `f(x) && g(x) && ...`
"""
function ∧ end
∧(f) = f
∧(f, g) = (x...) -> f(x...) && g(x...)
∧(f, g, h...) = ∧((f ∧ g), h...)
function ∨ end
∨(f) = f
∨(f, g) = (x...) -> f(x...) || g(x...)
∨(f, g, h...) = ∨((f ∨ g), h...)
julia> map(isascii ∧ isuppercase ∨ isdigit, ('A', '1', 'Σ'))
(true, true, false)
Note that evaluation is “kind-of-short-circuiting”; you can’t replicate && with a function, since it’s control flow, but the evaluation of the function chain will exit early if it hits a false (or true, depending). Also, all arguments to ∨ and ∧ are evaluated when the anonymous function is created (like with ifelse).
As an exercise a while back I also wrote a macro version of this to overcome the mentioned limitations, but I still haven’t been able to think of a single case where using it would be worthwhile…
macro and(args...)
ex = Expr(:&&, first(args))
ex′ = ex
for i in 2:length(args)
push!(ex′.args, Expr(:&&, args[i]))
ex′ = last(ex′.args)
end
esc(ex)
end
edit: sorry, I didn’t find the right version of the macro, so the above doesn’t do what I said it does. Oh well…