Pooh program example 17-for-range-lib.p

Test 17-for-range-lib.p

Source of programm


println( ~msg '*** growing integer range ***' )
for c range( ~from 0 ~to 5 )
  println( ~msg c )
end
println( ~msg '*** growing float range ***' )
for c range( ~from 0.2 ~to 5 )
  println( ~msg c )
end 
println( ~msg '*** growing float range (float step) ***' )
for c range( ~from 1 ~to 5 ~step 0.5 )
  println( ~msg c )
end 
println( ~msg '*** decreasing integer range ***' )
for c range( ~from 5 ~to 0 ~step -1 )
  println( ~msg c )
end
println( ~msg '*** decreasing float range ***' )
for c range( ~from 4.2 ~to 0 ~step -1 )
  println( ~msg c )
end 
println( ~msg '*** decreasing float range (float step) ***' )
for c range( ~from 5 ~to 1 ~step -0.5 )
  println( ~msg c )
end 


Standard output for 17-for-range-lib.p

*** growing integer range ***
0
1
2
3
4
5
*** growing float range ***
0.200000
1.200000
2.200000
3.200000
4.200000
*** growing float range (float step) ***
1.000000
1.500000
2.000000
2.500000
3.000000
3.500000
4.000000
4.500000
5.000000
*** decreasing integer range ***
5
4
3
2
1
0
*** decreasing float range ***
4.200000
3.200000
2.200000
1.200000
0.200000
*** decreasing float range (float step) ***
5.000000
4.500000
4.000000
3.500000
3.000000
2.500000
2.000000
1.500000
1.000000

Trace output for 17-for-range-lib.p

002|println( ~msg '*** growing integer range ***' )...
003|for ... range( ~from 0 ~to 5 )...
003| for c = 0
004|  println( ~msg c:0 )...
003| end
003| for ...
003| for c = 1
004|  println( ~msg c:1 )...
003| end
003| for ...
003| for c = 2
004|  println( ~msg c:2 )...
003| end
003| for ...
003| for c = 3
004|  println( ~msg c:3 )...
003| end
003| for ...
003| for c = 4
004|  println( ~msg c:4 )...
003| end
003| for ...
003| for c = 5
004|  println( ~msg c:5 )...
003| end
003| for ...
003| end # finish for loop
006| println( ~msg '*** growing float range ***' )...
007| for ... range( ~from 2.000000e-01 ~to 5 )...
007|  for c = 2.000000e-01
008|   println( ~msg c:2.000000e-01 )...
007|  end
007|  for ...
007|  for c = 1.200000e+00
008|   println( ~msg c:1.200000e+00 )...
007|  end
007|  for ...
007|  for c = 2.200000e+00
008|   println( ~msg c:2.200000e+00 )...
007|  end
007|  for ...
007|  for c = 3.200000e+00
008|   println( ~msg c:3.200000e+00 )...
007|  end
007|  for ...
007|  for c = 4.200000e+00
008|   println( ~msg c:4.200000e+00 )...
007|  end
007|  for ...
007|  end # finish for loop
010|  println( ~msg '*** growing float range (float step) ***' )...
011|  for ... range( ~from 1 ~to 5 ~step 5.000000e-01 )...
011|   for c = 1.000000e+00
012|    println( ~msg c:1.000000e+00 )...
011|   end
011|   for ...
011|   for c = 1.500000e+00
012|    println( ~msg c:1.500000e+00 )...
011|   end
011|   for ...
011|   for c = 2.000000e+00
012|    println( ~msg c:2.000000e+00 )...
011|   end
011|   for ...
011|   for c = 2.500000e+00
012|    println( ~msg c:2.500000e+00 )...
011|   end
011|   for ...
011|   for c = 3.000000e+00
012|    println( ~msg c:3.000000e+00 )...
011|   end
011|   for ...
011|   for c = 3.500000e+00
012|    println( ~msg c:3.500000e+00 )...
011|   end
011|   for ...
011|   for c = 4.000000e+00
012|    println( ~msg c:4.000000e+00 )...
011|   end
011|   for ...
011|   for c = 4.500000e+00
012|    println( ~msg c:4.500000e+00 )...
011|   end
011|   for ...
011|   for c = 5.000000e+00
012|    println( ~msg c:5.000000e+00 )...
011|   end
011|   for ...
011|   end # finish for loop
014|   println( ~msg '*** decreasing integer range ***' )...
015|   for ... range( ~from 5 ~to 0 ~step  - 1 )...
015|    for c = 5
016|     println( ~msg c:5 )...
015|    end
015|    for ...
015|    for c = 4
016|     println( ~msg c:4 )...
015|    end
015|    for ...
015|    for c = 3
016|     println( ~msg c:3 )...
015|    end
015|    for ...
015|    for c = 2
016|     println( ~msg c:2 )...
015|    end
015|    for ...
015|    for c = 1
016|     println( ~msg c:1 )...
015|    end
015|    for ...
015|    for c = 0
016|     println( ~msg c:0 )...
015|    end
015|    for ...
015|    end # finish for loop
018|    println( ~msg '*** decreasing float range ***' )...
019|    for ... range( ~from 4.200000e+00 ~to 0 ~step  - 1 )...
019|     for c = 4.200000e+00
020|      println( ~msg c:4.200000e+00 )...
019|     end
019|     for ...
019|     for c = 3.200000e+00
020|      println( ~msg c:3.200000e+00 )...
019|     end
019|     for ...
019|     for c = 2.200000e+00
020|      println( ~msg c:2.200000e+00 )...
019|     end
019|     for ...
019|     for c = 1.200000e+00
020|      println( ~msg c:1.200000e+00 )...
019|     end
019|     for ...
019|     for c = 2.000000e-01
020|      println( ~msg c:2.000000e-01 )...
019|     end
019|     for ...
019|     end # finish for loop
022|     println( ~msg '*** decreasing float range (float step) ***' )...
023|     for ... range( ~from 5 ~to 1 ~step  - 5.000000e-01 )...
023|      for c = 5.000000e+00
024|       println( ~msg c:5.000000e+00 )...
023|      end
023|      for ...
023|      for c = 4.500000e+00
024|       println( ~msg c:4.500000e+00 )...
023|      end
023|      for ...
023|      for c = 4.000000e+00
024|       println( ~msg c:4.000000e+00 )...
023|      end
023|      for ...
023|      for c = 3.500000e+00
024|       println( ~msg c:3.500000e+00 )...
023|      end
023|      for ...
023|      for c = 3.000000e+00
024|       println( ~msg c:3.000000e+00 )...
023|      end
023|      for ...
023|      for c = 2.500000e+00
024|       println( ~msg c:2.500000e+00 )...
023|      end
023|      for ...
023|      for c = 2.000000e+00
024|       println( ~msg c:2.000000e+00 )...
023|      end
023|      for ...
023|      for c = 1.500000e+00
024|       println( ~msg c:1.500000e+00 )...
023|      end
023|      for ...
023|      for c = 1.000000e+00
024|       println( ~msg c:1.000000e+00 )...
023|      end
023|      for ...
023|      end # finish for loop