James Andrew
James Andrew

Reputation: 7243

One item String List into a String in a Haskell program

I am using take 1 on a string list, so it takes the first string element from the list and puts it in a new list...

I.E: take 1 ["hello", "this", "is", "an", "example"]

Would output:

["hello"]

How can I make it so it outputs just:

"hello"

Is it easy?

(I only ever want the first element from a string list and I want it to output it as a string).

Upvotes: 1

Views: 347

Answers (1)

Tyler
Tyler

Reputation: 22116

That would be the head function. But be careful: If you call it on an empty list, you'll get an error.

Upvotes: 6

Related Questions