Logo

Programming-Idioms

  • Ada
  • Php
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 );
}
for Item of Items loop
   Do_Something (Item);
end loop;
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...