checat

Untitled

Jan 18th, 2021
958
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. take' ::(Num i, Ord i) => i -> [a] -> [a]
  2. take' n x = reverse' (take'' n x [])
  3.  where take'' n _ r
  4.          | n <= 0 = r
  5.        take'' _ [] r = r
  6.        take'' n (x:xs) r =  take'' (n - 1) xs (x:r)
  7.  
  8. reverse' :: [a] -> [a]
  9. reverse' x = reverse'' x []
  10.  where reverse'' [] r = r
  11.        reverse'' (x:xs) r = reverse'' xs (x:r)
  12.  
  13.  
RAW Paste Data