block expressions

by David Weldon

I’ve long been annoyed that list comprehensions can only accept a single expression. What if I want to print and perform some computation on each value? What I didn’t know was that expressions can be grouped together as blocks:

> [begin erlang:display(N), N*10 end || N <- lists:seq(1,3)].
1
2
3
[10,20,30]

For more details see this.

Advertisements