@partially-applied/enumerate-binary-set
v0.0.2
Published
generates binary number line
Downloads
2
Readme
@partially-applied/enumerate-binary-set
For a given integer10 x , it generates the range of integers2 up to x.
To view it in another way, it lists the binary number line up to a given value ( in base 10 ).
Quick Guide in Code
enumerate = require "@partially-applied/enumerate-binary-set"
enumerate 1 # [ [ 0 ] ]
enumerate 2 # [ [ 0 ] , [ 1 ] ]
enumerate 3 # [ [ 0 ], [ 1 ], [ 1, 0 ] ]
# Use of padding to normalize array length
# maintain a minimum length of 2
enumerate 3,2 # [ [ 0, 0 ], [ 0, 1 ], [ 1, 0 ] ]
# maintain a minimum length of 3
enumerate 3,3 # [ [ 0, 0, 0 ], [ 0, 0, 1 ], [ 0, 1, 0 ] ]
type signature
:: (range,padding) -> [[Int,..Int]..[Int,..Int]]
API
range
- should be a base 10 value
- should be an integer
- first argument provides the number of values you want to enumerate from 0.
padding
padding is a helper argument that adds zeros to the start of the value in case its shorter then the padding value