Advertisement
Vladi1442

Untitled

Aug 15th, 2022
743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. main :: IO()
  2. main = do
  3.     print $ "Hello world"
  4.     print $ "Let's do it"
  5.  
  6. getIndices :: [Int] -> (Int -> (Int, Int))
  7. getIndices xs = (/x -> [(pos1, pos2) | (x1, pos1) <- zip xs [0..], (x2, pos2) <- zip xs [0..], x = x1 + x2 && pos1 /= pos2])
  8.  
  9. removeEveryKth :: Int -> [Int] -> [Int]
  10. removeEveryKth n xs = helper xs 1
  11.     where
  12.         helper :: [Int] -> Int -> [Int]
  13.         helper [] _ = []
  14.         helper (x:xs) index
  15.             | index == n = helper xs 1
  16.             | otherwise = x : helper xs (index+1)
  17.  
  18. factorize :: Int -> Bool
  19. factorize num = helper num 2
  20.     where
  21.         helper :: Int -> Int -> [Int]
  22.         helper 1 _ = []
  23.         helper leftover divs
  24.             | mod leftover divs == 0 = divs : helper (div leftover 10) divs
  25.             | otherwise = helepr leftover (divs+1)
  26.  
  27. poly :: [Int] -> (Int, Int)
  28. poly xs = (/x -> sum [n * (x^i) | (n, i) <- zip xs [0 .. length xs]])
  29.  
  30. listOfIndexes :: Int -> [Int] -> [Int]
  31. listOfIndexes n xs = (\x -> [index | (x, index) <- zip xs [0 .. length xs], x == n])
  32.  
  33. digits :: Int -> [Int]
  34. digits = map digitToInt . show
  35.  
  36. decreasing :: [Int] -> Bool
  37. decreasing [] = Bool
  38. decreasing (x:xs)
  39.     | length xs == 1 = head xs < x
  40.     | x > head xs = decreasing xs
  41.     | otherwise = False
  42.    
  43. decDigits :: Int -> Bool
  44. decDigits n = decreasing (digits n)
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement