Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- countEven :: Integral a => [a] -> Integer
- countEven = length . filter even
- countUntilMax :: Ord a => a -> Integer
- countUntilMax xs = length $ takeWhile (/= m) xs
- where m = maximum xs
- secondMax :: Ord a => [a] -> a
- secondMax xs = maximum $ filter (/= m) xs
- where m = maximum xs
- applyList :: [(a -> a -> a)] -> [[a]] -> [a]
- applyList fs xxs = foldl1 (\acc xs -> zipWith ($) fs' (zip acc xs)) xxs
- where fs' = map uncurry fs
- arrange2 :: a -> a -> Int -> [[a]]
- arrange2 x y n = foldl (\acc _ -> map (x :) acc ++ (map (y :) acc)) [[]] [1..n]
- parallelotope :: Ord a => [[a]] -> [[a]]
- parallelotope xxs = foldl (\acc fs -> (applyList fs xxs) : acc) [] ffs
- where ffs = arrange2 max min n
- n = length $ head xxs
Add Comment
Please, Sign In to add comment