

Task

Demonstrate a   for-loop   where the step-value is greater than one.



Related tasks

   Loop over multiple arrays simultaneously
   Loops/Break
   Loops/Continue
   Loops/Do-while
   Loops/Downward for
   Loops/For
   Loops/For with a specified step
   Loops/Foreach
   Loops/Increment loop index within loop body
   Loops/Infinite
   Loops/N plus one half
   Loops/Nested
   Loops/While
   Loops/with multiple ranges
   Loops/Wrong ranges


 
{def loops_for_with_a_specified_step
 {lambda {:a :b :step}
  {if {>= :a :b}
   then (end of loop)
   else :a {loops_for_with_a_specified_step {+ :a :step} :b :step}}}}  
-> loops_for_with_a_specified_step  
 
{loops_for_with_a_specified_step 0 10 2}
-> 0 2 4 6 8 (end of loop)
 
a more simple way:
 
{S.map {lambda {:i} :i} {S.serie 0 9 2}}
-> 0 2 4 6 8
 