1

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).

1

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah I was just about to answer myself saying i've solved it ('unwords' on the take 1 seems to work) Thanks anyway!
Another option, since String = [Char]: concat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.