Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. for example:
  2.  
  3. the 'setElements' doesnt compile:
  4.  
  5. my code:
  6.  
  7. setElement :: Int -> a -> [a] -> [a]
  8. setElement n x xs = if ((n < length xs) && n >= 0)
  9. then (take n xs) ++ [x] ++ (drop (n + 1) xs)
  10. else xs
  11.  
  12. setElements :: [(Int, a)] -> [a] -> [a]
  13. setElements = foldr (t l-> setElement (fst head t) (snd head t) l) []
  14.  
  15. how can i fix the error?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement