aboutsummaryrefslogtreecommitdiffhomepage
path: root/std/Number.bruijn
blob: f74b7d49555f819b186a4121aff51618f9f069eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# MIT License, Copyright (c) 2023 Marvin Borner
# this is just a reference to the ternary implementation
# read the wiki for the reasoning of using balanced ternary by default

:import std/List .

:input std/Number/Ternary

# the following functions are only here because of recursive imports of list/ternary

# converts a list of digits into a balanced ternary number
from-digits foldl [[(+10) ⋅ 1 + 0]] (+0)

:test (from-digits ((+4) : ((+2) : {}(+0)))) ((+420))
:test (from-digits empty) ((+0))