introducing_erlang.pdf

(5432 KB) Pobierz
2n
d
Ed
iti
on
Erlang
GETTING STARTED IN FUNCTIONAL PROGRAMMING
Introducing
Simon St.Laurent
Getting Started in Functional Programming
Introducing Erlang
Simon St.Laurent
Beijing
Boston Farnham Sebastopol
Tokyo
Introducing Erlang
by Simon St.Laurent
Copyright © 2017 Simon St.Laurent. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are
also available for most titles (http://oreilly.com/safari). For more information, contact our corporate/insti‐
tutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editor:
Dawn Schanafelt
Production Editor:
Colleen Lobner
Copyeditor:
Christina Edwards
Indexer:
WordCo Indexing Services
March 2017:
Second Edition
Interior Designer:
David Futato
Cover Designer:
Karen Montgomery
Illustrator:
Rebecca Demarest
Revision History for the Second Edition
2017-02-28:
First Release
See
http://oreilly.com/catalog/errata.csp?isbn=9781491973370
for release details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc.
Introducing Erlang,
the cover image of a
giant red flying squirrel, and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the author have used good faith efforts to ensure that the information and
instructions contained in this work are accurate, the publisher and the author disclaim all responsibility
for errors or omissions, including without limitation responsibility for damages resulting from the use of
or reliance on this work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is subject to open source
licenses or the intellectual property rights of others, it is your responsibility to ensure that your use
thereof complies with such licenses and/or rights.
978-1-491-97337-0
[LSI]
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1.
Getting Comfortable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Installation
Firing It Up
First Steps: The Shell
Moving through Text
Moving through History
Moving through Files
Doing Something
Calling Functions
Numbers in Erlang
Working with Variables in the Shell
Seeing Your Bound Variables
Clearing Bound Variables in the Shell
Fun with fun
Defining Modules
From Module to fun
Functions and Variable Scope
Module Directives
Documenting Code
Documenting Modules
Documenting Functions
Documenting Your Application
1
2
2
3
3
3
4
5
6
8
9
10
2.
Functions and Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
11
13
16
16
16
18
19
21
23
iii
Zgłoś jeśli naruszono regulamin