Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View 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")))

View 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"))