Logo

Programming-Idioms

  • Elixir
  • Js
for (var i = 0; i<items.length; i++) {
  var x = items[i];
  doSomething(x);
}
items.forEach((x) => {
    doSomething(x);
});
for (const x of items) {
	doSomething(x);
}
items.map(doSomething)

doSomething is a function
items.forEach(doSomething)

No anonymous function here, we pass a function directly to forEach
for x <- items do
  IO.inspect(x)
end
Enum.each(items, &IO.inspect/1)
for Item of Items loop
   Do_Something (Item);
end loop;

New implementation...