Rerouted (cache, verified). The original is gone. This copy comes from a Lamdera package cache made before it went. The Lamdera package server serves a copy recovered from a Lamdera package cache from 2021-02-13.
What we checked: Rebuilt from the unpacked sources in a Lamdera package cache (5 copies agree), which Elm only writes after the published SHA-1 checked out; elm.json is byte-identical to package.elm-lang.org's; the exposed modules match docs.json; the zip is our own, so its SHA-1 is not the published one.
The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.
Details · package.elm-lang.org's zip: https://github.com/malaire/elm-uint64/zipball/2.0.0/
Working with list of digits, e.g. padding digits and grouping digits.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 7654321
|> UInt64.toDigits Digits.decimal
|> Digits.groupToString 3 ' '
--> "7 654 321"
UInt64.fromInt 0xABCDE
|> UInt64.toDigits Digits.hexLower
|> Digits.padToPowerOfTwo '0'
|> Digits.toString
|> (++) "0x"
--> "0x000abcde"
UInt64.fromInt 0x10F
|> UInt64.toDigits Digits.binary
|> Digits.padToMultipleOf 4 '0'
|> Digits.pad 32 '.'
|> Digits.groupToString 4 ' '
--> ".... .... .... .... .... 0001 0000 1111"
UInt64.fromInt 0x1FF
|> UInt64.toIntDigits Digits.octal
|> Digits.toList
--> [ 7, 7, 7 ]See also UInt64.toDigits and UInt64.toIntDigits.
Base used with toDigits and toIntDigits
to convert UInt64 to Digits.
Hexadecimal aka base 16, using uppercase characters.
toDigits: 0123456789ABCDEFHexadecimal aka base 16, using lowercase characters.
toDigits: 0123456789abcdefThe padding value given to these functions is not checked or validated in any way. It can be any value and doesn't need to be a valid digit.
Pad to given number of digits.
Int: 1 <= x <= 64See argument handling.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 271
|> UInt64.toDigits Digits.binary
|> Digits.pad 32 '0'
|> Digits.toString
--> "00000000000000000000000100001111"Pad to even number of digits.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 271
|> UInt64.toDigits Digits.binary
|> Digits.padToEven '0'
|> Digits.toString
--> "0100001111"Pad to multiple of given number of digits.
For example padToMultipleOf 16 would pad to 0, 16, 32, 48 or 64 digits.
Int: 1 <= x <= 64See argument handling.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 271
|> UInt64.toDigits Digits.binary
|> Digits.padToMultipleOf 4 '0'
|> Digits.toString
--> "000100001111"Pad to 2^n digits, i.e. to 0, 1, 2, 4, 8, 16, 32 or 64 digits.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 271
|> UInt64.toDigits Digits.binary
|> Digits.padToPowerOfTwo '0'
|> Digits.toString
--> "0000000100001111"Apply a function to every digit.
If Digits has been padded, then function is also applied to added padding, if any.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 11
|> UInt64.toIntDigits Digits.binary
|> Digits.map ((==) 1)
|> Digits.toList
--> [ True, False, True, True ]Convert Digits of Char to String.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 7654321
|> UInt64.toDigits Digits.decimal
|> Digits.toString
--> "7654321"Convert Digits of Char to String of grouped digits.
Groups are separated by given separator.
groupSize: 1 <= x <= 64See argument handling.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 7654321
|> UInt64.toDigits Digits.decimal
|> Digits.groupToString 3 ' '
--> "7 654 321"Convert Digits to List of digits.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 7654321
|> UInt64.toDigits Digits.decimal
|> Digits.toList
--> [ '7', '6', '5', '4', '3', '2', '1' ]Convert Digits to List of digits with list length.
This is O(1) while List.length is O(n), so if you need list length then
using this is faster than toList followed by List.length.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 7654321
|> UInt64.toDigits Digits.decimal
|> Digits.toListWithLength
--> ( 7, [ '7', '6', '5', '4', '3', '2', '1' ] )Convert Digits to flat List of grouped digits.
Groups are separated by given separator.
groupSize: 1 <= x <= 64See argument handling.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 7654321
|> UInt64.toDigits Digits.decimal
|> Digits.groupToFlatList 3 ' '
--> [ '7', ' ', '6', '5', '4', ' ', '3', '2', '1' ]Convert Digits to List of grouped digits.
Each group will be a separate sub-List.
groupSize: 1 <= x <= 64See argument handling.
import UInt64
import UInt64.Digits as Digits
UInt64.fromInt 7654321
|> UInt64.toDigits Digits.decimal
|> Digits.groupToList 3
--> [ [ '7' ], [ '6', '5', '4' ], [ '3', '2', '1' ] ]
List of digits.