Introducing Elixir by Simon St. Laurent & J. David Eisenberg

Introducing Elixir by Simon St. Laurent & J. David Eisenberg

Author:Simon St. Laurent & J. David Eisenberg [Unknown]
Language: eng
Format: epub
ISBN: 9781449369996
Publisher: O’Reilly Media, Inc.
Published: 2014-10-06T20:00:00+00:00


Note

The result of the List.foldl is the same as 32/(16/(8/(4/(2/(1/1))))), while the result of the List.foldr is the same as 1/(2/(4/(8/(16/(32/1))))). The parentheses in those perform the same restructuring as the fold, and the concluding 1 in each is where the initial accumulator value fits in.

Folding is an incredibly powerful operation. This simple if slightly weird example just used a single value, a number, as an accumulator. If you use a tuple as the accumulator, you can store all kinds of information about a list as it passes by and even perform multiple operations. You probably won’t want to try to define the functions you use for that as one-liners, but the possibilities are endless.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.