Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cutting a string into a list in Haskell?

is it possible to cut a string eg

"one , Two"

to a list

["one", "two"]

or just

"one", "two"

thanks

like image 326
Tom Avatar asked Dec 22 '22 14:12

Tom


1 Answers

There's a whole module of functions for different strategies to split a list (such as a string, which is just a list of characters): Data.List.Split

Using this, you could do

import Data.List.Split

> splitOn " , " "one , Two"
["one","Two"]
like image 192
Frerich Raabe Avatar answered Jan 06 '23 17:01

Frerich Raabe