diff -r 6dfa8001eed2 -r f8be66557e0f src/FunctionalProgramming.jl --- a/src/FunctionalProgramming.jl Wed Dec 15 01:09:09 2021 +0200 +++ b/src/FunctionalProgramming.jl Wed Dec 22 11:13:38 2021 +0200 @@ -17,7 +17,8 @@ ############## export curry, - curryflip + curryflip, + maybe ########### # Currying @@ -57,4 +58,12 @@ return x ->f(x, y...; kwargs...) end +""" +`maybe(f, x)` + +Returns `nothing` if `x` is `nothing, otherwise `f(x)`. +""" +maybe( :: Function, :: Nothing) = nothing +maybe(f :: Function, x :: T) where T = f(x) + end # module