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
-- The list where nth element is the list of strings of length n. | |
strings = iterate (map (:) letters <*>) letterStrings | |
where letterStrings = map (:[]) letters | |
letters = ['a'..'z'] |
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
guard(pred, f) = if pred then f! | |
g(x) -> | |
y = getY! | |
<~ guard (x != y) | |
x + y |
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 Control.Monad | |
import Data.Maybe | |
import Prelude hiding (any, elem) | |
import Data.Foldable | |
type State = String | |
type Map a b = [(a, b)] | |
-- In Map State (Map Char (m State)), the monad m determines the kind of FSM that is being run. | |
-- If m = [] (or Set), these functions work as a NFA. If m = Maybe, we essentially have a DFA. |
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 qualified Data.Map as M | |
import Control.Arrow ((>>>)) | |
import Data.List (intercalate) | |
import GHC.Exts (sortWith) | |
main = interact $ words | |
>>> foldr incr M.empty | |
>>> M.toList | |
>>> sortWith (negate . snd) | |
>>> map show |
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
ps = [] : map parts [1..] | |
where parts n = [n] : [x : p | x <- [1..n], p <- ps !! (n - x), x <= head p] |
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
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE NamedFieldPuns #-} | |
{-# LANGUAGE RecordWildCards #-} | |
import System.Directory (getDirectoryContents) | |
import qualified System.IO.Strict as S | |
import Data.String.Utils (split, join) | |
import qualified Data.HashMap.Lazy as M | |
import qualified Data.HashSet as H | |
import qualified Data.ByteString.Lazy as B |
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 (scanl, length, takeWhile, sum, map) | |
import Data.List.Stream | |
import System.Random.Mersenne.Pure64 | |
import qualified Data.Set as S | |
import Data.Word | |
randUpTo :: Int -> PureMT -> [Int] | |
randUpTo n gen = unfoldr make gen | |
where make g = let (k, g') = randomInt g in Just (k `mod` n, g') |
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
{-# LANGUAGE GADTs, StandaloneDeriving, RankNTypes #-} | |
type Var = String | |
data RecT a | |
data SendT a | |
data RepT a | |
data ParT a b | |
data NilT | |
data NuT a |
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
{-# LANGUAGE GADTs #-} | |
import Data.Char (digitToInt) | |
data Nil | |
data Cons a b | |
data Pipeline ts a c where | |
(:>) :: (a -> b) -> Pipeline ts b c -> Pipeline (Cons (a -> b) ts) a c | |
Id :: Pipeline Nil t t |
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
Elm.Native.EltMouse = function(elm){ | |
'use strict'; | |
elm.Native = elm.Native || {}; | |
if (elm.Native.EltMouse) return elm.Native.EltMouse; | |
var Utils = Elm.Native.Utils(elm); | |
function EltClicks(input) { | |
this.id = Utils.guid(); |
OlderNewer