Size in Haskell

Find this useful? Support us: Star on GitHub 6
Category: Array | Language: Haskell

To get the size of an array in Haskell, you can use the length function which takes an array as an input and returns its size as an integer.

For example, let's say we have an array of integers:

myArray = [1, 2, 3, 4, 5]

We can get the size of this array by using the length function:

arraySize = length myArray

This will set the arraySize variable to 5 which is the size of the myArray.

Another example of getting the size of a string array:

myStringArray = ["apple", "banana", "orange", "grape"]
stringArraySize = length myStringArray

This will set the stringArraySize variable to 4 which is the size of the myStringArray.