I would like to have a parser that can transform a string "[1,2,3,4,5] into an elm List [1,2,3,4,5]
I want to user loop for this and I am getting somewhere with this great post: https://korban.net/posts/elm/2018-09-07-introduction-elm-parser/
With that I was able to get here so far: https://ellie-app.com/4V96cbjjrKta1
So not exactly, but getting closer. Now unfortunately I cannot wrap my head around this part of the code:
stringHelp : List String -> Parser (Step (List String) (List String)) stringHelp nums = let checkNum numsSoFar num = if String.length num > 0 then Loop (num :: numsSoFar) else Done (List.reverse numsSoFar) in succeed (checkNum nums) |= (getChompedString <| chompWhile Char.isDigit)
The variables checkNum, numsSoFar and num don’t seem to be defined anywhere? How can I do String.length on num? I don’t have a definition of num before or inside the let closure.
checkNum numsSoFar num = if String.length num > 0 then
I am sure I am missing something rather basic, pointing me to docs or tutorials to understand this would be a huge help too.
Edit. OK I understand let checkNum numsSoFar num now, basically checkNum is a function with arguments numSoFar and num. But I still struggle with num, where is that coming from? Also because after let we do a partial function call inside in without num?