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.180 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.179 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.178 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.177 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.176 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.175 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.174 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.173 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.172 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.171 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.170 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.169 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.167 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.166 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.165 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.164 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.163 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.162 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.161 tracks/scheme/exercises/raindrops/example.scm
trackler-2.2.1.160 tracks/scheme/exercises/raindrops/example.scm