Programmer_Passport_Elixir.pdf

(2803 KB) Pobierz
Programmer Passport: Elixir
Bruce Tate
The Pragmatic Bookshelf
Raleigh, North Carolina
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, PragProg and the linking
g
device are trade-
marks 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.
For our complete catalog of hands-on, practical, and Pragmatic content for software devel-
opers, please visit
https://pragprog.com
.
The team that produced this book includes:
CEO: Dave Rankin
COO: Janet Furlow
Managing Editor: Tammy Coron
Development Editor: Jacquelyn Carter
Copy Editor: Corina Lebegioara
Founders: Andy Hunt and Dave Thomas
For sales, volume licensing, and support, please contact
support@pragprog.com
.
For international rights, please contact
rights@pragprog.com
.
Copyright © 2022 The Pragmatic Programmers, LLC.
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system,
or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording,
or otherwise, without the prior consent of the publisher.
ISBN-13: 978-1-68050-962-5
Encoded using the finest acid-free high-entropy binary digits.
Book version: P1.0—May 2022
Contents
1.
Preface
.
.
.
.
.
.
.
.
.
.
Sweet Tooling
.
.
.
.
.
.
.
.
Based on Erlang
Beyond Erlang
Tools
Mix Manages Development Tasks
IEx: Interactive Elixir
Built-in Testing
Custom Mix Tasks
Sound Dependency Management Fuels Adoption
Your Turn
Data and Code Organization
.
.
.
.
.
Atoms, Pattern Matching, and Erlang Access
Booleans and Truthy Expressions
Numerics Favor Utility over Performance
Characters Are Code Points
Elixir Deemphasizes Control Structures
Your Turn
Tuples and Functions
.
.
.
.
.
.
Tuples, Deconstruction, and Pattern Matching
Functions and Code Organization
Advanced Pattern Matching and Constructors
Your Turn
Lists and Algorithms
.
Lists
Pattern Matching and Lists
Recursion over Lists
.
.
.
.
.
.
.
.
.
.
.
.
.
.
v
1
2
3
5
5
7
10
11
13
16
19
20
25
26
27
28
31
33
33
36
41
44
45
45
49
51
2.
.
.
.
3.
.
.
.
.
4.
.
.
.
.
Zgłoś jeśli naruszono regulamin