I am currently writing a code in SML that takes in a string list full of numbers and spaces. The code must combine the numbers up to the space, then create a new list item for the next set of numbers, and so on.
For example, the list ["1", "", "2", "3", "", "4", "5", "6"] would return the list ["1", "23", "456"].
My current non-error attempt includes the code below.
fun conc(L) =
case L of
[] => ""
| x::xs => x ^ conc(xs);
fun intParse(L as x::xs) =
let
val intStr = conc(L)
in
intStr :: intParse(xs)
end;
I wanted to write something like the code below, but couldn't without error. This is not exact code, more-so pseudocode that I couldn't figure out.
fun strToInt(nil) = []
| strToInt(L) =
let
fun conc(y::ys) =
if hd(ys) <> "" then y ^ conc(ys)
else y ^ ""
in
conc(L) :: strToInt(xs)
end;