Last active
January 13, 2020 12:50
-
-
Save phagenlocher/0587b9f2b80f26958d525aa36e9dbbaa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| elem :: (Eq a) => a -> [a] -> Bool | |
| elem _ [] = False | |
| elem e (x:xs) = (e == x) || (elem e xs) | |
| nub :: (Eq a) => [a] -> [a] | |
| nub [] = [] | |
| nub (x:xs) | |
| | x `elem` xs = nub xs | |
| | otherwise = x : nub xs | |
| isAsc :: [Int] -> Bool | |
| isAsc [] = True | |
| isAsc [x] = True | |
| isAsc (x:y:xs) = (x <= y) && isAsc (y:xs) | |
| hasPath :: [(Int,Int)] -> Int -> Int -> Bool | |
| hasPath [] x y = x == y | |
| hasPath xs x y | |
| | x == y = True | |
| | otherwise = | |
| let xs' = [ (n,m) | (n,m) <- xs, n /= x ] in | |
| or [ hasPath xs' m y | (n,m) <- xs, n == x ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment