Introducing Erlang by Simon St.Laurent
Author:Simon St.Laurent
Language: eng
Format: epub, mobi
Publisher: O'Reilly Media, Inc.
Published: 2017-02-28T05:00:00+00:00
Example 8-4. Using the return value of the receive clause as state for the next iteration
-module(bounce). -export([report/1]). report(Count) -> NewCount = receive X -> io:format("Received #~p: ~p~n",[Count,X]), Count + 1 end, report(NewCount).
In this model, all (though just one here) of the receive clauses return a value that gets passed to the next iteration of the function. If you use this approach, you can think of the return value of the receive clause as the state to be preserved between function calls. That state can be much more intricate than a counter—it might be a tuple, for instance, that includes references to important resources or work in progress.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(26289)
Hello! Python by Anthony Briggs(25214)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(24445)
Kotlin in Action by Dmitry Jemerov(23533)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(22877)
Dependency Injection in .NET by Mark Seemann(22666)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(21428)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(20272)
Grails in Action by Glen Smith Peter Ledbrook(19341)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(17054)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(16365)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(14077)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(12254)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(11530)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10643)
Hit Refresh by Satya Nadella(9219)
The Kubernetes Operator Framework Book by Michael Dame(8579)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8432)
Robo-Advisor with Python by Aki Ranin(8376)