https://github.com/sourcevault/enumerate-binary-set
generates binary number line
https://github.com/sourcevault/enumerate-binary-set
Last synced: 5 months ago
JSON representation
generates binary number line
- Host: GitHub
- URL: https://github.com/sourcevault/enumerate-binary-set
- Owner: sourcevault
- License: mit
- Created: 2016-10-03T09:55:21.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-03T09:57:31.000Z (over 9 years ago)
- Last Synced: 2026-01-18T14:19:19.838Z (5 months ago)
- Language: LiveScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
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**
```livescript
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