Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Mocha example code
- # Copyright 2011 Brian Mock
- use graphics
- function plus(x, y) {
- return x + y
- }
- procedure hello: world {
- print "Hello ", world, "!"
- }
- procedure greet: time, name {
- print "Good ", time, ", ", name
- }
- procedure triangle: n {
- for x in 1 ... 5
- for y in 1 ... x {
- write "#"
- }
- print
- }
- }
- procedure even_or_odd {
- for x in 1 ... 5 {
- if odd(x) {
- print x, " is odd"
- }
- else {
- print x, " is even"
- }
- }
- }
- procedure print_triangles {
- input := prompt("Number> ")
- until input = "quit" or input = "q" {
- num = integer(input)
- triangle num
- }
- }
- procedure main {
- even_or_odd
- print_triangles
- }
Add Comment
Please, Sign In to add comment