Download Functional Programming Using Calm Light by Mauny M. PDF

By Mauny M.

Show description

Read or Download Functional Programming Using Calm Light PDF

Best programming books

Beginning Perl (3rd Edition)

This can be a ebook for these people who believed that we didn’t have to examine Perl, and now we all know it truly is extra ubiquitous than ever. Perl is intensely versatile and strong, and it isn’t frightened of net 2. zero or the cloud. initially touted because the duct tape of the net, Perl has because developed right into a multipurpose, multiplatform language current totally all over: heavy-duty net functions, the cloud, platforms management, common language processing, and monetary engineering.

Additional info for Functional Programming Using Calm Light

Example text

You can get into serious trouble, how‐ ever, if your termination test relies on == or === for comparison to a single value rather than >= or <= for comparison to a range. Recursing with Return Values The counting examples are simple—they demonstrate how recursion works, but just discard the return values. puts calls return the atom :ok—but they aren’t of much use. More typically, a recursive function call will make use of the return value. A classic recursive call calculates factorials. A factorial is the product of all positive integers equal to or less than the argument.

Usually, atoms are bits of text that start with a colon, like :ok or :earth or :Today. They can also contain underscores (_) and at symbols (@), like :this_is_a_short_sen tence or :me@home. If you want more freedom to use spaces, you can start with the colon, and then put them in single quotes, like :'Today is a good day'. Generally, the one-word lowercase form is easier to read. Atoms have a value—it’s the same as their text: iex(1)> :test :test That’s not very exciting in itself. What makes atoms exciting is the way that they can combine with other types and Elixir’s pattern-matching techniques to build simple but powerful logical structures.

Example 2-6, in ch02/ex5-import, shows a simple use of import to bring in all the func‐ tions (and macros, though there aren’t any yet) in the Convert module. Example 2-6. fall_velocity(meters)) end end The import Convert line tells Elixir that all of the functions and macros (except those starting with underscore) in the Convert module should be available without prefixes in this module. Importing an Erlang module, shown in Example 2-7, is much the same, except that you prefix the module name with a colon and don’t start the name with an uppercase letter: Example 2-7.

Download PDF sample

Rated 4.29 of 5 – based on 30 votes