Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Prelude hiding (take, drop)
- take :: Int -> [a] -> [a]
- take 0 _ = []
- take n [] = []
- take n (x:xs) = x: take (n - 1) xs
- drop :: Int -> [a] -> [a]
- drop 0 xs = xs
- drop n [] = []
- drop n (x:xs) = drop (n - 1) xs
- takeDrop :: Int -> [a] -> ([a],[a])
- takeDrop 0 xs = ([],xs)
- takeDrop n [] = ([],[])
- takeDrop n (x:xs) = (x:first,second)
- where
- (first,second) = takeDrop (n - 1) xs
- --is_elem_of :: a -> [a] -> Bool
- is_elem_of element [] = False
- is_elem_of element (x:xs) = (x == element) || (is_elem_of element xs)
- intersection [] _ = []
- intersection _ [] = []
- intersection (x:xs) (y:ys)
- |is_elem_of x (y:ys) = x: intersection xs (y:ys)
- |otherwise = intersection xs (y:ys)
- func [] ys _ _ = []
- func (x:xs) ys (z:zs) xs_lst
- |is_elem_of x inter = z: func xs ys zs xs_lst
- |otherwise = x: func xs ys zs xs_lst
- where
- inter = intersection xs_lst ys
- main_func xs ys zs = func xs ys zs xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement