Sha256: 96a12db3f30535eda318cb769ca6885f5bb536bead107b64d8150a07e52d9806
Contents?: true
Size: 881 Bytes
Versions: 396
Compression:
Stored size: 881 Bytes
Contents
(define-module (raindrops) #:export (convert)) (define prime-factors (lambda (n) (let loop ((n n) (m 2) (factors '())) (cond ((= n 1) factors) ((= 0 (modulo n m)) (loop (/ n m) 2 (cons m factors))) (else (loop n (+ 1 m) factors)))))) (define convert (lambda (n) (let ((drops "") (factors (filter (lambda (v) (and (>= v 3) (<= v 7))) (prime-factors n)))) (if (not (null? factors)) (begin (when (member 3 factors) (set! drops (string-append drops "Pling"))) (when (member 5 factors) (set! drops (string-append drops "Plang"))) (when (member 7 factors) (set! drops (string-append drops "Plong")))) (set! drops (string-append drops (number->string n)))) drops)))
Version data entries
396 entries across 396 versions & 1 rubygems