Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/General-FizzBuzz/Racket/general-fizzbuzz-1.rkt
Normal file
19
Task/General-FizzBuzz/Racket/general-fizzbuzz-1.rkt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#lang racket/base
|
||||
|
||||
(define (get-matches num factors/words)
|
||||
(for*/list ([factor/word (in-list factors/words)]
|
||||
[factor (in-value (car factor/word))]
|
||||
[word (in-value (cadr factor/word))]
|
||||
#:when (zero? (remainder num factor)))
|
||||
word))
|
||||
|
||||
(define (gen-fizzbuzz from to factors/words)
|
||||
(for ([num (in-range from to)])
|
||||
(define matches (get-matches num factors/words))
|
||||
(displayln (if (null? matches)
|
||||
(number->string num)
|
||||
(apply string-append matches)))))
|
||||
|
||||
(gen-fizzbuzz 1 21 '((3 "Fizz")
|
||||
(5 "Buzz")
|
||||
(7 "Baxx")))
|
||||
17
Task/General-FizzBuzz/Racket/general-fizzbuzz-2.rkt
Normal file
17
Task/General-FizzBuzz/Racket/general-fizzbuzz-2.rkt
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#lang racket
|
||||
(require racket/match)
|
||||
|
||||
(define (fizz-buzz-individual x . args)
|
||||
(match (string-append*
|
||||
(map (lambda (i)
|
||||
(match i
|
||||
[(cons a b) (if (= 0 (modulo x a)) b "")])) args))
|
||||
["" x]
|
||||
[fizz-buzz-string fizz-buzz-string]))
|
||||
|
||||
(define (fizz-buzz x . args)
|
||||
(map (curryr (compose displayln (curry apply fizz-buzz-individual)) args)
|
||||
(range 1 (add1 x)))
|
||||
(void))
|
||||
|
||||
(fizz-buzz 20 '(3 . "Fizz") '(5 . "Buzz") '(7 . "Baxx"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue