Pooh program example 03-print-table.p

Test 03-print-table.p

Source of programm

# iterate over table and print out values.

days =  {
          'sun'  : 'Sunday',
          'mon'  : 'Monday' ,
          'tue'  : 'Tuesday' ,
          'wed'  : 'Wednesday' ,
          'thur' : 'Thursday' ,
          'fri'  : 'Friday' ,
          'sat'  : 'Shabbat'
        }

daykeys = keys( ~table days )
i = 1

println( ~msg '**** value { keys  } ***' )

while daykeys[ i ] != Null
    println( ~msg  days{ daykeys[ i ] }   )
    i = i + 1
end

println( ~msg '*** value ***' )

daykeys = values( ~table days )
i = 1

while daykeys[ i ] != Null
    println( ~msg  daykeys[ i ]    )
    i = i + 1
end

println( ~msg '*** each ***' )
v = each(  ~table days )

i = 1
while i <= size( ~arg v )
  e = v[ i ] 
  println( ~msg e[ 1 ] )
  println( ~msg e[ 2 ] )
  i = i + 1
end

Standard output for 03-print-table.p

**** value { keys  } ***
Monday
Friday
Tuesday
Thursday
Shabbat
Sunday
Wednesday
*** value ***
Monday
Friday
Tuesday
Thursday
Shabbat
Sunday
Wednesday
*** each ***
mon
Monday
fri
Friday
tue
Tuesday
thur
Thursday
sat
Shabbat
sun
Sunday
wed
Wednesday

Trace output for 03-print-table.p

003|days = { 'sun' : 'Sunday' , 'mon' : 'Monday' , 'tue' : 'Tuesday' , 'wed' : 'Wednesday' , 'thur' : 'Thursday' , 'fri' : 'Friday' , 'sat' : 'Shabbat' }
013|... = keys( ~table days:{ 'mon' : -> 'Monday', 'fri' : -> 'Friday', 'tue' : -> 'Tuesday', 'thur' : -> 'Thursday', 'sat' : -> 'Shabbat', 'sun' : -> 'Sunday', 'wed' : -> 'Wednesday' } )...
013|daykeys = keys( ~table days:{ 'mon' : -> 'Monday', 'fri' : -> 'Friday', 'tue' : -> 'Tuesday', 'thur' : -> 'Thursday', 'sat' : -> 'Shabbat', 'sun' : -> 'Sunday', 'wed' : -> 'Wednesday' } ):[ 'mon', 'fri', 'tue', 'thur', 'sat', 'sun', 'wed' ]
014|i = 1
016|println( ~msg '**** value { keys  } ***' )...
018|while (daykeys[i:1]:'mon' != Null):true
019| println( ~msg days{daykeys[i:1]:'mon'}:'Monday' )...
020| i = (i:1 + 1):2
021|end
018|while (daykeys[i:2]:'fri' != Null):true
019| println( ~msg days{daykeys[i:2]:'fri'}:'Friday' )...
020| i = (i:2 + 1):3
021|end
018|while (daykeys[i:3]:'tue' != Null):true
019| println( ~msg days{daykeys[i:3]:'tue'}:'Tuesday' )...
020| i = (i:3 + 1):4
021|end
018|while (daykeys[i:4]:'thur' != Null):true
019| println( ~msg days{daykeys[i:4]:'thur'}:'Thursday' )...
020| i = (i:4 + 1):5
021|end
018|while (daykeys[i:5]:'sat' != Null):true
019| println( ~msg days{daykeys[i:5]:'sat'}:'Shabbat' )...
020| i = (i:5 + 1):6
021|end
018|while (daykeys[i:6]:'sun' != Null):true
019| println( ~msg days{daykeys[i:6]:'sun'}:'Sunday' )...
020| i = (i:6 + 1):7
021|end
018|while (daykeys[i:7]:'wed' != Null):true
019| println( ~msg days{daykeys[i:7]:'wed'}:'Wednesday' )...
020| i = (i:7 + 1):8
021|end
018|while (daykeys[i:8]:Null != Null):false
021|end # finish loop
023|println( ~msg '*** value ***' )...
025|... = values( ~table days:{ 'mon' : -> 'Monday', 'fri' : -> 'Friday', 'tue' : -> 'Tuesday', 'thur' : -> 'Thursday', 'sat' : -> 'Shabbat', 'sun' : -> 'Sunday', 'wed' : -> 'Wednesday' } )...
025|daykeys = values( ~table days:{ 'mon' : -> 'Monday', 'fri' : -> 'Friday', 'tue' : -> 'Tuesday', 'thur' : -> 'Thursday', 'sat' : -> 'Shabbat', 'sun' : -> 'Sunday', 'wed' : -> 'Wednesday' } ):[ -> 'Monday', -> 'Friday', -> 'Tuesday', -> 'Thursday', -> 'Shabbat', -> 'Sunday', -> 'Wednesday' ]
026|i = 1
028|while (daykeys[i:1]:'Monday' != Null):true
029| println( ~msg daykeys[i:1]:'Monday' )...
030| i = (i:1 + 1):2
031|end
028|while (daykeys[i:2]:'Friday' != Null):true
029| println( ~msg daykeys[i:2]:'Friday' )...
030| i = (i:2 + 1):3
031|end
028|while (daykeys[i:3]:'Tuesday' != Null):true
029| println( ~msg daykeys[i:3]:'Tuesday' )...
030| i = (i:3 + 1):4
031|end
028|while (daykeys[i:4]:'Thursday' != Null):true
029| println( ~msg daykeys[i:4]:'Thursday' )...
030| i = (i:4 + 1):5
031|end
028|while (daykeys[i:5]:'Shabbat' != Null):true
029| println( ~msg daykeys[i:5]:'Shabbat' )...
030| i = (i:5 + 1):6
031|end
028|while (daykeys[i:6]:'Sunday' != Null):true
029| println( ~msg daykeys[i:6]:'Sunday' )...
030| i = (i:6 + 1):7
031|end
028|while (daykeys[i:7]:'Wednesday' != Null):true
029| println( ~msg daykeys[i:7]:'Wednesday' )...
030| i = (i:7 + 1):8
031|end
028|while (daykeys[i:8]:Null != Null):false
031|end # finish loop
033|println( ~msg '*** each ***' )...
034|... = each( ~table days:{ 'mon' : -> 'Monday', 'fri' : -> 'Friday', 'tue' : -> 'Tuesday', 'thur' : -> 'Thursday', 'sat' : -> 'Shabbat', 'sun' : -> 'Sunday', 'wed' : -> 'Wednesday' } )...
034|v = each( ~table days:{ 'mon' : -> 'Monday', 'fri' : -> 'Friday', 'tue' : -> 'Tuesday', 'thur' : -> 'Thursday', 'sat' : -> 'Shabbat', 'sun' : -> 'Sunday', 'wed' : -> 'Wednesday' } ):[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ]
036|i = 1
037|while (i:1 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] )...
037|while (i:1 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] ):7):true
038| e = v[i:1]:[ 'mon', -> 'Monday' ]
039| println( ~msg e[1]:'mon' )...
040| println( ~msg e[2]:'Monday' )...
041| i = (i:1 + 1):2
042|end
037|while (i:2 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] )...
037|while (i:2 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] ):7):true
038| e = v[i:2]:[ 'fri', -> 'Friday' ]
039| println( ~msg e[1]:'fri' )...
040| println( ~msg e[2]:'Friday' )...
041| i = (i:2 + 1):3
042|end
037|while (i:3 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] )...
037|while (i:3 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] ):7):true
038| e = v[i:3]:[ 'tue', -> 'Tuesday' ]
039| println( ~msg e[1]:'tue' )...
040| println( ~msg e[2]:'Tuesday' )...
041| i = (i:3 + 1):4
042|end
037|while (i:4 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] )...
037|while (i:4 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] ):7):true
038| e = v[i:4]:[ 'thur', -> 'Thursday' ]
039| println( ~msg e[1]:'thur' )...
040| println( ~msg e[2]:'Thursday' )...
041| i = (i:4 + 1):5
042|end
037|while (i:5 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] )...
037|while (i:5 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] ):7):true
038| e = v[i:5]:[ 'sat', -> 'Shabbat' ]
039| println( ~msg e[1]:'sat' )...
040| println( ~msg e[2]:'Shabbat' )...
041| i = (i:5 + 1):6
042|end
037|while (i:6 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] )...
037|while (i:6 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] ):7):true
038| e = v[i:6]:[ 'sun', -> 'Sunday' ]
039| println( ~msg e[1]:'sun' )...
040| println( ~msg e[2]:'Sunday' )...
041| i = (i:6 + 1):7
042|end
037|while (i:7 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] )...
037|while (i:7 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] ):7):true
038| e = v[i:7]:[ 'wed', -> 'Wednesday' ]
039| println( ~msg e[1]:'wed' )...
040| println( ~msg e[2]:'Wednesday' )...
041| i = (i:7 + 1):8
042|end
037|while (i:8 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] )...
037|while (i:8 <= size( ~arg v:[ [ 'mon', -> 'Monday' ], [ 'fri', -> 'Friday' ], [ 'tue', -> 'Tuesday' ], [ 'thur', -> 'Thursday' ], [ 'sat', -> 'Shabbat' ], [ 'sun', -> 'Sunday' ], [ 'wed', -> 'Wednesday' ] ] ):7):false
042|end # finish loop