Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
14
Task/FizzBuzz/Shen/fizzbuzz-1.shen
Normal file
14
Task/FizzBuzz/Shen/fizzbuzz-1.shen
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(define fizzbuzz
|
||||
101 -> (nl)
|
||||
N -> (let divisible-by? (/. A B (integer? (/ A B)))
|
||||
(cases (divisible-by? N 15) (do (output "Fizzbuzz!~%")
|
||||
(fizzbuzz (+ N 1)))
|
||||
(divisible-by? N 3) (do (output "Fizz!~%")
|
||||
(fizzbuzz (+ N 1)))
|
||||
(divisible-by? N 5) (do (output "Buzz!~%")
|
||||
(fizzbuzz (+ N 1)))
|
||||
true (do (output (str N))
|
||||
(nl)
|
||||
(fizzbuzz (+ N 1))))))
|
||||
|
||||
(fizzbuzz 1)
|
||||
29
Task/FizzBuzz/Shen/fizzbuzz-2.shen
Normal file
29
Task/FizzBuzz/Shen/fizzbuzz-2.shen
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
(defprolog fizz
|
||||
0 <-- (is _ (output "Fizz"));
|
||||
N <-- (when (> N 0)) (is N1 (- N 3)) (fizz N1);
|
||||
)
|
||||
|
||||
(defprolog buzz
|
||||
0 <-- (is _ (output "Buzz"));
|
||||
N <-- (when (> N 0)) (is N1 (- N 5)) (buzz N1);
|
||||
)
|
||||
|
||||
(define none
|
||||
[] -> true
|
||||
[true | _] -> false
|
||||
[_ | B] -> (none B)
|
||||
)
|
||||
|
||||
(define fizzbuzz
|
||||
N M -> (nl) where (> N M)
|
||||
N M -> (do
|
||||
(if (none [(prolog? (receive N) (fizz N)) (prolog? (receive N) (buzz N))])
|
||||
(output (str N))
|
||||
(output "!")
|
||||
)
|
||||
(nl)
|
||||
(fizzbuzz (+ N 1) M)
|
||||
)
|
||||
)
|
||||
|
||||
(fizzbuzz 1 100)
|
||||
Loading…
Add table
Add a link
Reference in a new issue