Sha256: 5b7c59ece16a61738efde96af550765eee58024083333a5b7de55f699979b247

Contents?: true

Size: 865 Bytes

Versions: 396

Compression:

Stored size: 865 Bytes

Contents

(defmodule beer-song
  (export (verse 1)
          (sing 1)
          (sing 2)))

(defun bottles
  ([0] "no more bottles")
  ([1] "1 bottle")
  ([n] (io_lib:format "~B bottles" `(,n))))

;; -spec verse(non_neg_integer()) -> iolist().
(defun verse
  ([0]
   (++ "No more bottles of beer on the wall, no more bottles of beer.\n"
       "Go to the store and buy some more, 99 bottles of beer on the wall.\n"))
  ([n] (when (andalso (is_integer n) (=< 0 n)))
   (io_lib:format
     (++ "~s of beer on the wall, ~s of beer.\n"
         "Take it down and pass it around, ~s of beer on the wall.\n")
     `(,(bottles n) ,(bottles n) ,(bottles (- n 1))))))

;; -spec sing(non_neg_integer()) -> iolist().
(defun sing
  ([n] (when (andalso (is_integer n) (=< 0 n)))
   (sing n 0)))

(defun sing (from to)
  (lists:map (lambda (n) `(,(verse n) "\n")) (lists:seq from to -1)))

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.179 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.178 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.177 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.176 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.175 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.174 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.173 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.172 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.171 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.170 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.169 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.167 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.166 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.165 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.164 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.163 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.162 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.161 tracks/lfe/exercises/beer-song/src/example.lfe
trackler-2.2.1.160 tracks/lfe/exercises/beer-song/src/example.lfe