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
| mergeUniq (x : xs) (y : ys) = if x < y | |
| then x : mergeUniq xs (y : ys) | |
| else if y < x | |
| then y : mergeUniq (x : xs) ys | |
| else x : mergeUniq xs ys | |
| mergeUniq xs [] = xs | |
| mergeUniq [] ys = ys | |
| mult n = map (* n) [1..] |
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
| import Random | |
| import Graphics.Rendering.OpenGL | |
| import Data.IORef | |
| import Graphics.UI.GLUT | |
| lim_stanga = -10 :: Integer | |
| lim_dreapta = 9 :: Integer | |
| lim_sus = 9 :: Integer | |
| lim_jos = -9 :: Integer |
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
| module Main where | |
| import Control.Monad | |
| data S = C | C1 | C2 | C3 | D | O Integer deriving (Eq, Show) | |
| data A = A | Is deriving (Eq, Show) | |
| props = [(C3, A, O 3), (C2, A, O 2), (C1, Is, C3), (C2, Is, C3), (C, Is, C1), (C, Is, C2), (D, A, O 0)] | |
| find f s lst = [x | x@(s', _, _) <- lst, s == s', f x] `mplus` concat [find f p lst | (s', Is, p) <- lst, s == s'] |
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
| module Main where | |
| parts n = parts' 1 n where | |
| parts' _ 0 = [[]] | |
| parts' p n = concatMap (\x -> (map . (:)) x $ parts' x $ n - x) [p .. n] |
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
| import Control.Monad | |
| data T = L | B T T | |
| instance Show T where | |
| show L = "L" | |
| show (B left right) = 'B' : (show left ++ show right) | |
| newtype Parser a = Parser (String -> (a, String)) |
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
| module Main (main) where | |
| import Prelude hiding (lookup) | |
| import Data.Map (empty, insertWith', keys, lookup, size) | |
| import System.Random (getStdRandom, randomR) | |
| import Control.Monad (liftM) | |
| import System.Environment (getArgs) | |
| parse (a : b : c : t) = insertWith' comb (a, b) ([c], 1) $ parse $ b : c : t | |
| where comb (l, m) (r, n) = (l ++ r, m + n) |
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
| module Main where | |
| import Data.List | |
| data Ord a => Tree a = Node a (Tree a) (Tree a) | Leaf a | |
| deriving (Eq) | |
| val (Node a _ _) = a | |
| val (Leaf a) = a | |
| instance (Show a, Ord a) => Show (Tree a) where |
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
| module Main where | |
| import Data.List | |
| expand (x, y) = [(0, y), (x, 0), (v1, y), (x, v2), (x - d1, y + d1), (x + d2, y - d2)] where | |
| d1 = min x (v2 - y) | |
| d2 = min y (v1 - x) | |
| v1 = 17 | |
| v2 = 13 |
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
| module Main where | |
| import Control.Monad | |
| newtype Parser a = Parser (String -> [(a, String)]) | |
| parse (Parser p) = p | |
| instance Monad Parser where | |
| return r = Parser (\s -> [(r, s)]) |
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
| module Main where | |
| import Data.Map | |
| import GHC.Handle | |
| import GHC.IOBase | |
| data Room = Room | |
| { | |
| location :: String, | |
| description :: String, |