string is a list of characters in Haskell. We can get the length of the string using the
length function takes a list as a parameter. Since the
string is a list of characters, we can pass the string as a parameter and get its length.
length function returns the length of a string as an integer.
Let's take a look at an example of this.
main::IO() main = do let str = "Hello from Educative!!!" -- Get the string length print(length str)
lengthfunction to retrieve the length of the string and print it using the
View all Courses