September 2013
Intermediate to advanced
548 pages
12h 25m
English
We are going on a walking tour and are lucky enough to have a module that we can use to plan our walks. The module starts like this:
| walks.erl | |
| | -module(walks). |
| | -export([plan_route/2]). |
| | |
| | -spec plan_route(point(), point()) -> route(). |
| | |
| | -type direction() :: north | south | east | west. |
| | -type point() :: {integer(), integer()}. |
| | -type route() :: [{go,direction(),integer()}]. |
...
This module exports a function called plan_route/2.
The input and return types for the function are specified
in a type specification, and three new types
are defined using type declarations.
These are interpreted as follows:
-spec plan_route(point(), point()) ->
route().Means that if the function plan_route/2 is called ...
Read now
Unlock full access