Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Negate a predicate in Elixir

Tags:

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 ?

like image 882
Vincent J Avatar asked Sep 16 '25 17:09

Vincent J


1 Answers

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

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

like image 160
CoderDennis Avatar answered Sep 18 '25 10:09

CoderDennis