Home   Manual   Type Index   Symbol Index   Topics Index

std_types::association_list/std::for_each

iterates over all items of the association list

Parameters

self

the association list to iterate over

body

the statement sequence to execute for each item

return (optional; default value: pass)

used to return results to the caller

Description

For each item the statement sequence supplied as body is called with one or two arguments (depending on body's parameter count).

If called with two arguments the first argument is the key and the second argument the corresponding value.

If called with one argument then only the value is supplied.

This is a sequential loop.

Implements

std::for_each

Example

$ages empty_association_list
!ages("Tom") 5
!ages("Sam") 3
!ages("Sarah") 11
for_each ages: (name age)
  writeln! name ": " age
  next

Output

Sarah: 11
Sam: 3
Tom: 5