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

Version Path
trackler-2.2.1.139 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.138 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.137 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.136 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.135 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.134 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.133 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.132 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.131 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.130 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.129 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.128 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.127 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.126 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.125 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.124 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.123 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.122 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.121 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.120 tracks/scheme/exercises/raindrops/example.scm