Sha256: 09686a2f3f567de211a1532d69f01a85aea7efb396831319594e161a5fd08b4e
Contents?: true
Size: 388 Bytes
Versions: 396
Compression:
Stored size: 388 Bytes
Contents
(defmodule trinary (export (to-decimal 1))) (defun BASE () 3) (defun to-decimal (string) (to-decimal string 0)) (defun to-decimal ([() acc] acc) ([`(,digit . ,digits) acc] (when (>= digit #\0) (=< digit #\2)) (to-decimal digits (+ (digit->int digit) (* acc (BASE))))) ([_string _acc] 0)) (defun digit->int ([digit] (when (>= digit #\0) (=< digit #\2)) (- digit #\0)))
Version data entries
396 entries across 396 versions & 1 rubygems