O'Reilly logo

Programming Elixir by Dave Thomas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Your Turn

  • Exercise: Functions-4

    Write a function prefix that takes a string. It should return a new function that takes a second string. When that second function is called, it will return a string containing the first string, a space, and the second string.

     
    iex>​ mrs = prefix.(​"Mrs"​)
     
    #Function<erl_eval.6.82930912>​​​
     
    iex>​ mrs.(​"Smith"​)
     
    "Mrs Smith"​​​
     
    iex>​ prefix.(​"Elixir"​).(​"Rocks"​)
     
    "Elixir Rocks"

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required