loops

for( var x <- Range ){
   statement(s);
}

 for( var a <- 1 to 10){
     println( "Value of a: " + a );
 }

Ranges

i to j // includes j
i until j //excludes j

Can use multiple ranges separate by ; and will iterator over al combos of both

for( a <- 1 to 3; b <- 1 to 3){
    println( "Value of a: " + a );
    println( "Value of b: " + b );
}

(1, 1) -> (1, 2) -> (1, 3) -> (2, 1) -> ...

Containers

Can also be containers

With Filters/Guards

can filter out with if in for loop

With Yield

Creates a new data structue from an existing one

Last updated