You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

control-flow.l2 870B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. print "If"
  2. if 'true {print "true is true"} {print "true is not true"}
  3. if 'false {print "false is true"} {print "false is not true"}
  4. if 'true {print "true is true"}
  5. if 'false {print "false is true"} # This should output nothing
  6. print (if 'true {"If returns its true value"})
  7. print (if 'false {0} {"If returns its false value"})
  8. print "\nRun loop 10 times"
  9. i := 0
  10. loop {
  11. print "Hello World"
  12. i = i + 1
  13. if i >= 10 {'stop}
  14. }
  15. print "\nWith while this time"
  16. i := 0
  17. while {i < 10} {
  18. print "Hallo Wrodl"
  19. i = i + 1
  20. }
  21. print "\nAnd with the for loop"
  22. i := 0
  23. iter := {
  24. j := i
  25. i = i + 1
  26. if j < 10 {j} {'stop}
  27. }
  28. for iter {print "Hello with" $}
  29. print "\nArray iterator"
  30. array-iter := {
  31. arr := $.0
  32. idx := 0
  33. {
  34. if idx >= (len arr) {
  35. 'stop
  36. } {
  37. j := idx
  38. idx = idx + 1
  39. [j arr.(j)]
  40. }
  41. }
  42. }
  43. for (array-iter ["hello" "world" "how" "are" "you" 10 20 'true]) print