Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Little Twelve Toes

Little Twelve Toes

Extending Elixir to support base-12 numbering

Cameron Price

October 27, 2016
Tweet

More Decks by Cameron Price

Other Decks in Programming

Transcript

  1. 10 = 5 * 2 12 = 3 * 2

    * 2 = 3 * 4 = 2 * 6
  2. 0..9 : The same 10 : X (pronounced ‘dec’) 11

    : E (pronounced ‘el’) 12 : 10 (pronounced ‘do’)
  3. Now we can say: 32X7 is “three mo two gro

    dec do seven” Easy peasy…
  4. def sigil_d(s, []), do: s |> String.split(".") |> _construct def

    _construct([w]), do: w |> Dozenex.Integer. construct
  5. defimpl String.Chars, for: Dozenex.Integer do def to_string(%Dozenex.Integer{digits: digits}) , do:

    digits |> Dozenex.Integer. _convert_to_char_list |> Kernel.to_string end defimpl Inspect, for: Dozenex.Integer do def inspect(di, _opts), do: "~d(#{di})" end
  6. NYI • Infix operators for +, -, *, /, and

    .. • Floating point support
  7. NYI • Infix operators for +, -, *, /, and

    .. • Floating point support • Mixed Dozenal / Decimal math
  8. Learn more: • http://dozenal.org/ (The Dozenal Society of America) •

    https://en.wikipedia.org/wiki/Duodecimal • https://en.wikipedia.org/wiki/Decimal#Other_bases