Ad
  • Custom User Avatar

    Bugger. I suspect, comparing the elm wiki page with the ruby one that the packages are currently limited to elm/core and elm-explorations/test. If so, that's pretty limiting. Without it, I suppose one could manually copypaste the whole Regex module in to the preloaded section, but that seems clumsy. Summary: I don't know.

  • Custom User Avatar

    This could also be solved arguably more neatly via a Regex e.g.

    import Regex
    
    stripComments : String -> List Char -> String
    stripComments input markers =
        let
            markersString =
                String.concat <|
                    List.map (\marker -> "\\" ++ String.fromChar marker) markers
            regex =
                Maybe.withDefault Regex.never <|
                    Regex.fromString ("[ \t]*[" ++ markersString ++ "].*")
        in
        Regex.replace regex (\_ -> "") input
    

    One other thought is that the markers input could be a List String rather than a List Char. I don't know what Elm best practice is here. I suppose there is some benefit to forcing the list to be single characters rather than allow a multi-character through.

  • Custom User Avatar

    To get this working I needed a shuffle which isn't natively provided by the Random library. I've pulled in the relevant functions from elm-community/random-extra and owanturist/elm-union-find packages. Bit annoying though.

  • Custom User Avatar

    That's a fair point. I'm still learning the Elm test framework so I'll have a think about how to go about this.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Elm translation for review.