Logo

Programming-Idioms

Do something with each item x of the list (or array) items, regardless indexes.
Implementation
Scheme

Implementation edit is for fixing errors and enhancing with metadata. Please do not replace the code below with a different implementation.

Instead of changing the code of the snippet, consider creating another Scheme implementation.

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
for (Item x: items) {
    doSomething(x);
}
for x in items:
        doSomething( x )
for _, x := range items {
    doSomething(x)
}
for (unsigned int i = 0 ; i < items_length ; ++i){
        Item* x = &(items[i]);
	DoSomethingWith(x);
}
items.each{|x| do_something( x )}
items.forEach((x) => {
    doSomething(x);
});
for (x of items) {
	doSomething(x);
}
(define (doSomething x)
    (if (not (null? x))
        (begin 
            (display "Item=")
            (display (car x))
            (newline)
            (doSomething (cdr x)))))
for(int i=0;i<items.length;i++){
	doSomething( items[i] );
}
items.forEach(doSomething);
foreach ($items as $x){
    doSomething( $x );
}
do_something($_) for @items;
for x in items {
	do_something(x);
}
foreach(x; items) {
	doSomethingWith(x);
}
for x in items do ;
import Control.Monad
forM_ items doSomething
(map do-something items)
Enum.each(items, &IO.inspect/1)
[do_something(X) || X <- Items]
lists:foreach(fun do_something/1, Items).
for(const auto &x : items) {
	doSomething(x);
}
foreach (var x in items)
{
    DoSomething(x);
}
for _, x in ipairs(items) do
	print(x)
end
for Item of Items loop
   Do_Something (Item);
end loop;
items.foreach{doSomething(_)}
items.each do |x|
  do_something( x )
end
for my $x (@items) {
     do_something($x);
     more_stuffs($x);
}
import std.algorithm.iteration;
items.each!(a => writeln(a))();
(map nil #'something items)
items.stream().forEach(item -> doSomething(item));
items |> List.iter do_something
items.forEach { doSomething(it) }
items.forEach(::doSomething)
array_map(func, $items);
items.forEach(doSomething)
elemental subroutine foo(x)
  real, intent(in) :: x
end subroutine foo

call foo(x)
for (size_t i = 0; i < sizeof(items) / sizeof(items[0]); i++) {
	DoSomethingWith(&items[i]);
}
For Each x In items
    DoSomething(x)
Next
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 (x in items) doSomething(x)
for (id x in items) _doSomething(x);
items.each { x -> doSomething(x) }
for(x in items) doSomething(x)
for (var i = 0; i<items.length; i++) {
  var x = items[i];
  doSomething(x);
}
items.each { doSomething(it) }
items.foreach(doSomething)
for {
  x <- items
} doSomething(x)
(map doSomething items)
items.into_iter().for_each(|x| do_something(x));
items do: [:x | x doSomething]
items.map(doSomething)
for x <- items do
  IO.inspect(x)
end
[do_something(x) for x in items]
import java.util.List;
for(T item : items) {
	System.out.println(item);
}