friedbrice / elm-teaching-tools / ElmTeachingTools.Lib.String

Extra functions to make working with strings easier.

toInts : String -> Maybe (List Basics.Int)

Parse a comma-separated list of ints.

--| Example.
toInts "2,3,4,-1"
--> Just [2, 3, 4, -1]

--| Entire parse fails if parsing any element fails.
toInts "2,3,lolwut,-1"
--> Nothing

fromInts : List Basics.Int -> String

Print a comma-separated list of ints.

--| Example.
fromInts [2, 3, 4, -1]
--> "2,3,4,-1"

format : { prefix : String, infix : String, suffix : String } -> (a -> String) -> List a -> String

Format a list into a string.

--| Example.
format { prefix = "<", infix = ":", suffix = ">" } String.fromInt [3,4,5]
--> "<3:4:5>"