You are viewing a single comment's thread. Return to all comments →
Solution in Haskell.
--Only fill up the blanks for the function named len --Do not modify the structure of the template in any other way len :: [a] -> Int len lst = sum [ 1 | _ <- lst ]
Here, we map our array and change all it's values to 1s, after which we add those values together and get the result.
1
Note: _ marks that the value we are not interested in.
_
Seems like cookies are disabled on this browser, please enable them to open this website
List Length
You are viewing a single comment's thread. Return to all comments →
Solution in Haskell.
Here, we map our array and change all it's values to
1
s, after which we add those values together and get the result.Note:
_
marks that the value we are not interested in.