Sha256: fc0a1437e2db33503665ed15996a847cffb9358a5236ca1f6a77ae8fa6f865fe

Contents?: true

Size: 289 Bytes

Versions: 396

Compression:

Stored size: 289 Bytes

Contents

(defmodule binary-string
  (export (to-decimal 1)))

(defun to-decimal (string)
  (try (element 2 (lists:foldr #'to-decimal/2 #(0 0) string))
    (catch (_ 0))))

(defun to-decimal
  ([#\0 `#(,n ,acc)] `#(,(+ n 1) ,acc))
  ([#\1 `#(,n ,acc)] `#(,(+ n 1) ,(+ acc (trunc (math:pow 2 n))))))

Version data entries

396 entries across 396 versions & 1 rubygems

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