Perl 6 Parallelism in Perl 6 #27

Parallel list generators (race)

@results := map { .say; $_ * 2 }, @data;
# nothing output yet, map is lazy

@results := eager map { .say; $_ * 2 }, @data;
# eager evaluation forced
# each element of @data printed in sequence

@results = hyper map { .say; $_ * 2 }, @data;
# elements of @data printed in any order
# @results same order as @data

@results = race map { $_ ** 2 }, @data;
# elements of @data printed in any order
# @results also may be in any order

See Synopsis 2 for more on eager/hyper/race.

Copyright © 2013
http://www.pmichaud.com/2013/pres/