Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Elixir

Idiom #35 First-class function : compose

Implement a function compose (A -> C) with parameters f (A -> B) and g (B -> C), which returns the composition function g ∘ f

def compose(f, g) do
  fn a ->
    g.(f.(a))
  end
end
(defn compose [f g]
   (comp g f))

New implementation...
< >
programming-idioms.org