This file contains 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
prime :: Int -> Int | |
prime n = last $ take n $ preparePrime [2, 3 ..] | |
where preparePrime (x:xs) = [x] ++ [y | y <- xs, y `mod` x /= 0] |
This file contains 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 Game where | |
import Data.Array | |
import System.Random | |
import Prelude hiding (Either(..)) | |
data Move = Up | Down | Left | Right deriving (Enum) | |
type Label = Int | |
type Pos = (Int, Int) |
This file contains 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 Debug.Trace | |
-- trace :: String -> a -> a | |
echo :: Show a => a -> a | |
echo a = trace (show a) a | |
fib' :: Int -> Int | |
fib' 0 = 1 | |
fib' n = echo $ n * fib' (n - 1) |
This file contains 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
traversalTree :: Tree () -> State Integer (Tree Integer) | |
traversalTree (Leaf _) = do | |
n <- get | |
put (n + 1) | |
return (Leaf n) | |
traversalTree (Fork left cur right) = do | |
left' <- traversalTree left | |
n <- get | |
put (n + 1) | |
right' <- traversalTree right |
This file contains 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 Prelude hiding (lookup) | |
class MapLike m where | |
empty :: m k v | |
lookup :: Ord k => k -> m k v -> Maybe v | |
insert :: Ord k => k -> v -> m k v -> m k v | |
delete :: Ord k => k -> m k v -> m k v | |
fromList :: Ord k => [(k,v)] -> m k v | |
newtype ArrowMap k v = ArrowMap { getArrowMap :: k -> Maybe v } |
This file contains 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 Prelude hiding (lookup) | |
import qualified Data.List as L | |
class MapLike m where | |
empty :: m k v | |
lookup :: Ord k => k -> m k v -> Maybe v | |
insert :: Ord k => k -> v -> m k v -> m k v | |
delete :: Ord k => k -> m k v -> m k v | |
fromList :: Ord k => [(k,v)] -> m k v | |
fromList [] = empty |
This file contains 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 Data.Char(isDigit) | |
data Error = ParsingError | IncompleteDataError | IncorrectDataError String | |
deriving (Show) | |
data Person = Person { firstName :: String, lastName :: String, age :: Int } | |
deriving (Show) | |
split delimiter = foldr f [[]] | |
where f c l@(x:xs) | c == delimiter = []:l |
This file contains 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
var titleToNumber = function (str) { | |
var result = 0; | |
str.split('').reverse().forEach(function (ch, index) { | |
result += (ch.charCodeAt(0) - 64) * Math.pow(26, index); | |
}); | |
return result; | |
} |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test Select form Matreshka</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> | |
<link href="http://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.min.css" rel="stylesheet" /> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script> | |
<script src="http://cdn.jsdelivr.net/matreshka/latest/matreshka.min.js"></script> | |
</head> | |
<body> |
This file contains 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 Data.Char | |
import Data.List | |
readDigits :: String -> (String, String) | |
readDigits = span isDigit | |
filterDisj :: (a -> Bool) -> (a -> Bool) -> [a] -> [a] | |
filterDisj f g = filter (\x -> f x || g x) | |
qsort :: Ord a => [a] -> [a] |