Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
foreach ($items as $x){
    doSomething( $x );
}
array_map(func, $items);
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);
}
for (size_t i = 0; i < sizeof(items) / sizeof(items[0]); i++) {
	DoSomethingWith(&items[i]);
}
items |> List.iter do_something
(map do-something items)
IDENTIFICATION DIVISION.
PROGRAM-ID. list.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 LIST.
   03 X OCCURS 5 TIMES
        INDEXED BY i PIC 9.
PROCEDURE  DIVISION.       
    PERFORM VARYING i FROM 1  BY 1 UNTIL i > 5
        DISPLAY X(i)
    END-PERFORM    
STOP RUN.
for(const auto &x : items) {
	doSomething(x);
}
foreach (var x in items)
{
    DoSomething(x);
}
import std.algorithm.iteration;
items.each!(a => writeln(a))();
foreach(x; items) {
	doSomethingWith(x);
}
items.forEach(doSomething);
Enum.each(items, &IO.inspect/1)
for x <- items do
  IO.inspect(x)
end
[do_something(X) || X <- Items]
lists:foreach(fun do_something/1, Items).
elemental subroutine foo(x)
  real, intent(in) :: x
end subroutine foo

call foo(x)
for _, x := range items {
    doSomething(x)
}
items.each { x -> doSomething(x) }
for(x in items) doSomething(x)
items.each { doSomething(it) }
import Control.Monad
forM_ items doSomething
items.forEach(doSomething)
items.map(doSomething)
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);
}
T t;
Iterator<T> i = items.listIterator();
while (i.hasNext()) {
    t = i.next();
}
import java.util.Iterator;
T t;
Iterator<T> i = items.iterator();
while (i.hasNext()) {
    t = i.next();
}
for (T x : items) {}
for (Item x: items) {
    doSomething(x);
}
items.stream().forEach(item -> doSomething(item));
for(int i=0;i<items.length;i++){
	doSomething( items[i] );
}
for (x in items) doSomething(x)
items.forEach { doSomething(it) }
items.forEach(::doSomething)
(map nil #'something items)
for _, x in ipairs(items) do
	print(x)
end
for (id x in items) _doSomething(x);
for x in items do ;
do_something($_) for @items;
for my $x (@items) {
     do_something($x);
     more_stuffs($x);
}
f = lambda x: ...
for x in items: f(x)
[do_something(x) for x in items]
for x in items:
        doSomething( x )
items.each{|x| do_something( x )}
items.each do |x|
  do_something( x )
end
items.into_iter().for_each(|x| do_something(x));
for x in items {
	do_something(x);
}
items.foreach{doSomething(_)}
items.foreach(doSomething)
for {
  x <- items
} doSomething(x)
(define (sum a b)
 (sum-iter a b 0))

(define (sum-iter index n sum)
   (if (= n index)
    (+ sum index) 
    (+  (sum-iter  n (+ index 1) (+ sum index)))
 )
(map doSomething items)
(define (doSomething x)
    (if (not (null? x))
        (begin 
            (display "Item=")
            (display (car x))
            (newline)
            (doSomething (cdr x)))))
items do: [:x | x doSomething]
For Each x In items
    DoSomething(x)
Next

New implementation...