Question: In Haskell, For replicate function, why I have to write (Ord a, Num a) for type, rather than (Num a) or (Ord a) ? ===============================
In Haskell,
For replicate function, why I have to write (Ord a, Num a) for type, rather than (Num a) or (Ord a)?
===============================
replicate' :: (Ord a, Num a) => a -> a -> [a]
replicate' n x
| n <= 0 = []
| otherwise = x : replicate' (n - 1) x
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
