Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
90Activity
0 of .
Results for:
No results containing your search query
P. 1
Thinking in Erlang

Thinking in Erlang

Ratings:

4.97

(30)
|Views: 22,364 |Likes:
Published by rama09999

More info:

Published by: rama09999 on May 04, 2007
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

08/11/2013

pdf

text

original

 
Thinking in Erlang
A
GUIDE TO FUNCTIONAL PROGRAMMING IN
E
RLANG FOR THEEXPERIENCED PROCEDURAL DEVELOPER
Robert Baruch
autophile@zoominternet.netVersion 0.9.1
February 5, 2007
 
Thinking in Erlang RIGHT HEADER HERE
Copyright
This work is licensed under the Creative Commons Attribution-Share Alike 2.5 License. Toview a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/ or send a letterto Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.2
 
Thinking in Erlang RIGHT HEADER HERE
Contents
1 Introduction 4
1.1 What this document is not . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2 What this document is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.3 Porting code to Erlang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 Hello, World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.5 Compiling and running hello.erl . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 Scope of variables 7
2.1 No global state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2 Dealing with no global state . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3 Matching 9
3.1 Basic matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 Function argument matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.3 If and case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.4 Guards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4 Loops 14
4.1 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144.2 Less painful loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.3 Summary of less painful loops . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5 Processes 19
5.1 Doing two things at once . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.2 Interprocess communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205.3 Process termination reasons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215.4 Processes as objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225.5 Generic servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245.6 Distributed Erlang . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255.7 Synchronization not necessary . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
6 Dealing with errors 26
6.1 Let it fail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266.2 Workers and supervisors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
References 31
3

Activity (90)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Casey Robinson liked this
Dragan Polimac liked this
Ceejhay Cee liked this
Stas Kobzar liked this
573f liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->