Advertisement
karlicoss

primitive recursion

Nov 23rd, 2011
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. z :: [Int] -> Int
  3. z _ = 0
  4.  
  5. n :: [Int] -> Int
  6. n [x] = x + 1
  7. n _ = error "Bad argument" {- yep, not very informative, but who fcking cares? -}
  8.  
  9. u :: Int -> [Int] -> Int
  10. u index l
  11.     | index < (length l) = l !! index
  12.     | otherwise = error "Bad index"
  13.  
  14.  
  15. s :: ([Int] -> Int) -> [([Int] -> Int)] -> [Int] -> Int
  16. s f gl args = f $ map ($args) gl
  17.  
  18. r :: ([Int] -> Int) -> ([Int] -> Int) -> Int -> [Int] -> Int
  19. r f g 0 args = f args
  20. r f g y args = g $ [y - 1] ++ args ++ [r f g (y - 1) args]
  21.  
  22. main = do
  23.     putStrLn "hello"
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement