DEV Community

Discussion on: Daily Challenge #9 - What's Your Number?

Collapse
 
stevemoon profile image
Steve Moon

Erlang: (in the REPL)

Num = [8,0,0,5,5,5,1,2,1,2].
io:format("(~B~B~B) ~B~B~B-~B~B~B~B~n", Num).
(800) 555-1212
ok

Or you can use io_lib:format and assign the result to a variable instead.

Checking for valid input is fairly trivial, but the Erlang convention is to assume that something this far into the system is okay, and correct for the error by dying and letting the supervisor deal with it.