Vincent J
Vincent J

Reputation: 801

Negate a predicate in Elixir

Let say i have a predicate is_foo?/1 in Elixir I want to use it in a function taking a predicate as an argument, but negated. Is there a way in Elixir to do that simply ?

Upvotes: 4

Views: 2293

Answers (1)

CoderDennis
CoderDennis

Reputation: 13837

&(!is_foo? &1) should do it.

Or if you prefer the long form, fn x -> !is_foo? x end

Upvotes: 5

Related Questions