Logo

Programming-Idioms

  • PHP
  • Haskell
  • Clojure
(map do-something items)

do-something should be a function that receives a single argument. map returns a lazy seq, which means the function do-something won't be applied until the results are needed.
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.
foreach ($items as $x){
    doSomething( $x );
}
import Control.Monad
forM_ items doSomething
for Item of Items loop
   Do_Something (Item);
end loop;

New implementation...