["j","t","5","x","=","!"] Essentia...">

String to character list

I was wondering if I can convert a string to a list of characters?

"jt5x=!" -> ["j","t","5","x","=","!"]

Essentially, would that be?

example :: String -> [Char]
+4
source share
1 answer

(Gathering comments in response)

Since haskell a String has a list of characters, i.e. [Char], will just return the input as indicated, will do.

example = id

does what you want. Please note that idis defined as

id x = x

Your example "jt5x=!" -> ["j","t","5","x","=","!"]does not match the description: Double quotes ""are Stringnot enclosed by single Charactors. Single quotes are used for characters '. You can enter

"jt5x=!" == ['j','t','5','x','=','!']

in GHCi and see what it returns True. Enter map (:[]) "jt5x=!"to see ["j","t","5","x","=","!"].

+6

All Articles