Use asciiByte helper

This commit is contained in:
Ayaz Hafiz 2022-08-01 09:47:35 -05:00
parent e00ebbead7
commit a00953128d
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58

View file

@ -183,7 +183,9 @@ takeWhile = \list, predicate ->
Err _ -> {taken, rest}
helper {taken: [], rest: list}
digits = List.range 48u8 58u8
asciiByte = \b -> Num.toU8 b
digits = List.range (asciiByte '0') ((asciiByte '9') + 1)
takeDigits = \bytes ->
takeWhile bytes \n -> List.contains digits n
@ -194,9 +196,7 @@ takeFloat = \bytes ->
Ok 46 -> # 46 = .
{taken: floatPart, rest: afterAll} = takeDigits rest
builtFloat =
intPart
|> List.append (Num.intCast '.')
|> List.concat floatPart
List.concat (List.append intPart (asciiByte '.')) floatPart
{taken: builtFloat, rest: afterAll}
_ ->