Logo

Programming-Idioms

  • Ada
  • Go
  • Rust
  • Python
[do_something(x) for x in items]
for x in items:
        doSomething( x )
f = lambda x: ...
for x in items: f(x)
for Item of Items loop
   Do_Something (Item);
end loop;
for _, x := range items {
    doSomething(x)
}

You have to explicitly ignore the index loop variable, with the blank identifier _
for x in items {
	do_something(x);
}
items.into_iter().for_each(|x| do_something(x));
for (unsigned int i = 0 ; i < items_length ; ++i){
        Item* x = &(items[i]);
	DoSomethingWith(x);
}

items_length type is: unsigned int
DoSomethingWith prototype is: void DoSomethingWith(Item*);

New implementation...