Logo

Programming-Idioms

  • PHP
  • Haskell
import Control.Monad
forM_ items doSomething
foreach ($items as $x){
    doSomething( $x );
}
array_map(func, $items);

Function does need to be a real function and not a language construct, so you can't directly map _- (the unary negation operator) or other function like constructs like echo or print

Do note, this fails for iteratable non-arrays, the foreach based approach is better in that situation.
for Item of Items loop
   Do_Something (Item);
end loop;

New implementation...