Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
20
Task/FizzBuzz/Pyret/fizzbuzz.pyret
Normal file
20
Task/FizzBuzz/Pyret/fizzbuzz.pyret
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
is-positive = _ > 0 # equivalent to lam(x): x > 0 end
|
||||
|
||||
fun fizzbuzz(n :: Number%(is-positive)) -> String:
|
||||
doc: ```For positive input which is multiples of three return 'Fizz', for the multiples of five return 'Buzz'.
|
||||
For numbers which are multiples of both three and five return 'FizzBuzz'. Otherwise, return the number itself.```
|
||||
ask:
|
||||
| num-modulo(n, 15) == 0 then: "FizzBuzz"
|
||||
| num-modulo(n, 3) == 0 then: "Fizz"
|
||||
| num-modulo(n, 5) == 0 then: "Buzz"
|
||||
| otherwise: num-to-string(n)
|
||||
end
|
||||
where:
|
||||
fizzbuzz(1) is "1"
|
||||
fizzbuzz(101) is "101"
|
||||
fizzbuzz(45) is "FizzBuzz"
|
||||
fizzbuzz(33) is "Fizz"
|
||||
fizzbuzz(25) is "Buzz"
|
||||
end
|
||||
|
||||
range(1, 101).map(fizzbuzz).each(print)
|
||||
Loading…
Add table
Add a link
Reference in a new issue