Split a string by a chosen character in haskell

前端 未结 3 1489
北恋
北恋 2021-01-24 04:58

I\'m trying to split a string every time there is a chosen character. So if I receive \"1,2,3,4,5\", and my chosen character is \",\" the result is a l

3条回答
  •  一整个雨季
    2021-01-24 05:24

    If you're using GHC it comes with the standard Prelude and the modules in the base package, and perhaps a few other packages.

    Most packages, like the split package (which contains the Data.List.Split module), aren't part of GHC itself. You'll have to import them as an explicit compilation step. This is easiest done with a build tool. Most Haskellers use either Cabal or Stack.

    With Stack, for example, you can add the split package to your package.yaml file:

    dependencies:
    - base >= 4.7 && < 5
    - split
    

    You can also load an extra package when you use Stack to start GHCi. This is useful for ad-hoc experiments.

提交回复
热议问题