In this shot, we'll learn how to use Haskell to get the first character from a string. We can use the take
function provided by Haskell to get the first character from a string.
take n "provide string here"
Here, n
denotes the number of characters to get. We provide n = 1
to get the first character from the given string.
Let's see an example:
main::IO()main = do-- get first character from a stringprint(take 1 "hello world")
take
and pass n
as 1
.