mirror of
https://github.com/iritmaximus/haskell.git
synced 2026-10-12 19:13:39 +03:00
Set 4a Ex 5: reword, add challenge
This commit is contained in:
+6
-4
@@ -82,14 +82,16 @@ rangeOf :: [a] -> a
|
|||||||
rangeOf = todo
|
rangeOf = todo
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
-- Ex 5: given a list of lists, return the longest list. If there
|
-- Ex 5: given a (non-empty) list of (non-empty) lists, return the longest
|
||||||
-- are multiple lists of the same length, return the list that has
|
-- list. If there are multiple lists of the same length, return the list that
|
||||||
-- the smallest _first element_.
|
-- has the smallest _first element_.
|
||||||
--
|
--
|
||||||
-- (If multiple lists have the same length and same first element,
|
-- (If multiple lists have the same length and same first element,
|
||||||
-- you can return any one of them.)
|
-- you can return any one of them.)
|
||||||
--
|
--
|
||||||
-- Give the longest function a suitable type.
|
-- Give the function "longest" a suitable type.
|
||||||
|
--
|
||||||
|
-- Challenge: Can you solve this exercise without sorting the list of lists?
|
||||||
--
|
--
|
||||||
-- Examples:
|
-- Examples:
|
||||||
-- longest [[1,2,3],[4,5],[6]] ==> [1,2,3]
|
-- longest [[1,2,3],[4,5],[6]] ==> [1,2,3]
|
||||||
|
|||||||
Reference in New Issue
Block a user