In the introduction to the Orc language, we were introduced to lists: how to construct them, and how to match them against patterns. While it is certainly feasible to write a specific function with an appropriate pattern match every time we want to access a list, it is helpful to have a handful of common operations on lists and reuse them.
One of the most common uses for a list is to send each of its elements through
a sequential combinator. Since the list itself is a single value, we want
to walk through the list and publish each one of its elements in parallel
as a value. The library function each
does exactly that.
Suppose we want to send the message invite
to each email
address in the list inviteList
:
each(inviteList) >address> Email(address, invite)
Orc also adopts many of the list idioms of functional programming. The Orc library contains definitions
for most of the standard list functions, such as map
and fold
. Many of the
list functions internally take advantage of concurrency to make use of any available parallelism; for
example, the map
function dispatches all of the mapped calls concurrently, and assembles
the result list once they all return using a fork-join.