Logo

Programming-Idioms

Call a function f on each element e of a set x.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
(doseq [e x]
  (f e))
#include <algorithm>
std::for_each(x.begin(), x.end(), f);
for (auto e : x)
    f(e);
foreach(var e in x)
    f(e);
x.forEach(f);
for e := range x {
	f(e)
}
let v = x.values();
let result = v.next();
while (!result.done) {
  f(result.value);
  result = v.next();
}
x.forEach(f);
for (const e of x) {
	f(e);
}
import java.util.Set;
for(T e: x) {
  f(e);
}
for e in x do f(e);
f($_) for @x;
list(map(lambda e: f(e), x))
for e in x:
    f(e)
for e in x: f(e)
x.each { |e| f(e) }
use std::collections::HashSet;
for item in &x {
    f(item);
}