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: StringsAndBinaries-1

    Write a function that returns true if a single-quoted string contains only printable ASCII characters (space through tilde).

  • Exercise: StringsAndBinaries-3

    Try the following in iex:

     
    iex>​ [ ​'cat'​ | ​'dog'​ ]
     
    [​'cat'​,100,111,103]

    Why does iex print ’cat’ as a string, but ’dog’ as individual numbers?

  • Exercise: StringsAndBinaries-4

    (Hard) Write a function that takes a single-quoted string of the form number [+-*/] number and returns the result of the calculation. The individual numbers do not have leading plus or minus signs.

    calculate(’123 + 27’) # => 150

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