Guest User

Untitled

a guest
Jan 20th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. # Mocha example code
  2. # Copyright 2011 Brian Mock
  3.  
  4. use graphics
  5.  
  6. function plus(x, y) {
  7. return x + y
  8. }
  9.  
  10. procedure hello: world {
  11. print "Hello ", world, "!"
  12. }
  13.  
  14. procedure greet: time, name {
  15. print "Good ", time, ", ", name
  16. }
  17.  
  18. procedure triangle: n {
  19. for x in 1 ... 5
  20. for y in 1 ... x {
  21. write "#"
  22. }
  23.  
  24. print
  25. }
  26. }
  27.  
  28. procedure even_or_odd {
  29. for x in 1 ... 5 {
  30. if odd(x) {
  31. print x, " is odd"
  32. }
  33. else {
  34. print x, " is even"
  35. }
  36. }
  37. }
  38.  
  39. procedure print_triangles {
  40. input := prompt("Number> ")
  41. until input = "quit" or input = "q" {
  42. num = integer(input)
  43. triangle num
  44. }
  45. }
  46.  
  47. procedure main {
  48. even_or_odd
  49. print_triangles
  50. }
Add Comment
Please, Sign In to add comment