Programming Elixir_ Functional, Concurrent, Pragmatic, Fun [Thomas 2014-10-19].pdf

(1697 KB) Pobierz
Programming Elixir
Functional |> Concurrent |> Pragmatic |> Fun
by Dave Thomas
Copy right © 2014 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy -protect it because that would limit y our ability to use it for y our own purposes.
Please don't break this trust-don't allow others to use y our copy of the book. Thanks.
- Dave & Andy .
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was
aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic
Bookshelf and the linking
g
device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including
program listings) contained herein.
Our Pragmatic courses, workshops, and other products can help y ou and y our team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at
http://pragprog.com.
The team that produced this book includes: Ly nn Beighley (editor), Potomac Indexing, LLC (indexer), Candace Cunningham (copy editor), Janet Furlow (producer), Ellie Callahan (support).
For international rights, please contact
rights@pragprog.com.
No part of this publication may be reproduced, stored in a retrieval sy stem, or transmitted, in any form, or by any means, electronic, mechanical, photocopy ing, recording, or otherwise, without the prior
consent of the publisher.
Printed in the United States of America.
ISBN-13: 978-1-937785-58-1
Book version: P1.0—October, 2014
Table of Contents
Foreword
A Vain Attempt at a Justification
Acknowledgments
1. Take the Red Pill
Programming Should Be About Transforming Data
Installing Elixir
Running Elixir
Suggestions for Reading the Book
Exercises
Think Different(ly)
I. Conventional Programming
2. Pattern Matching
  
Assignment:
I Do Not Think It Means What You Think It Means.
   
More Complex Matches
   
Ignoring a Value with _ (Underscore)
   
Variables Bind Once (per Match)
   
Another Way of Looking at the Equals Sign
3. Immutability
   
You Already Have (Some) Immutable Data
   
Immutable Data Is Known Data
   
Performance Implications of Immutability
   
Coding with Immutable Data
4. Elixir Basics
   
Built-in Types
   
Value Types
   
System Types
   
Collection Types
   
Maps
   
Names, Source Files, Conventions, Operators, and So On
   
End of the Basics
5. Anonymous Functions
   
Functions and Pattern Matching
   
One Function, Multiple Bodies
   
Functions Can Return Functions
Zgłoś jeśli naruszono regulamin