Skip to Content
Erlang Programming
book

Erlang Programming

by Francesco Cesarini, Simon Thompson
June 2009
Intermediate to advanced
494 pages
14h 7m
English
O'Reilly Media, Inc.
Content preview from Erlang Programming

Chapter 2. Basic Erlang

This chapter is where we start covering the basics of Erlang. You may expect we’ll just be covering things you have seen before in programming languages, but there will be some surprises, whether your background is in C/CC++, Java, Python, or functional programming. Erlang has assignment, but not as you know it from other imperative languages, because you can assign to each variable only once. Erlang has pattern matching, which not only determines control flow, but also binds variables and pulls apart complex data structures. Erlang pattern matching is different in subtle ways from other functional languages. So, you’ll need to read carefully! We conclude the chapter by showing how to define Erlang functions and place them into modules to create programs, but we start by surveying the basic data types in Erlang.

Integers

Integers in Erlang are used to denote whole numbers. They can be positive or negative and expressed in bases other than 10. The notion of a maximum size of integers in Erlang does not exist, and so arbitrarily large whole numbers can be used in Erlang programming. When large integers do not fit in a word, they are internally converted to representation using an arbitrary number of words, more commonly known as bignums. While bignums give completely accurate calculation on arbitrary-size integers, this makes their implementation less efficient than fixed-size integers. The only limit on how large an integer can become depends on the physical ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Erlang, 2nd Edition

Programming Erlang, 2nd Edition

Joe Armstrong
Erlang and OTP in Action

Erlang and OTP in Action

Eric Merritt, Richard Carlsson, Martin Logan

Publisher Resources

ISBN: 9780596803940Errata PageSupplemental Content