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.List | |
newline [a] = [] | |
newline (a:b:xs) = abs (a-b) : (newline (b:xs)) | |
check prev [] = True | |
check prev line = all (`notElem` prev) line && nub line == line && check (line ++ prev) (newline line) | |
main = print $ filter (check []) $ concatMap permutations $ filter ((==5) . length) $ subsequences [1..15] |
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
-- Simple min/max algorithm playing a game with coins | |
-- | |
-- Rules: | |
-- > Initially, there is a stack of N coins | |
-- > Players take 1, 2 or 3 coins | |
-- > The player who takes the last coin loses | |
import Data.List (maximumBy, minimumBy) | |
import Data.Ord (comparing) | |
import System.IO |
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.List | |
coins :: [Int] | |
coins = [1, 2, 5, 10, 20, 50] | |
type CoinSet = [Int] | |
-- | All coinsets of a given length | |
draw :: Int -> [CoinSet] | |
draw 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 Main where | |
import Prelude | |
import Control.Monad (when) | |
import Control.Monad.Eff | |
import Control.Monad.Eff.Console | |
import Data.Int | |
import Data.Int.Bits | |
import Data.List |
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 Main where | |
import Prelude | |
import Data.Array (reverse) | |
import Data.Foldable (traverse_) | |
import Data.Monoid | |
import Data.Traversable (traverse) | |
import Control.Applicative.Free |
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 Main where | |
import Prelude | |
import Control.Apply ((*>)) | |
import Signal (Signal(), merge) | |
import Signal.Time (every, second) | |
import Flare (UI(), liftSF, button, foldp, runFlareShow) | |
tick :: Signal Int | |
tick = every second *> pure 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
module Main where | |
import Prelude | |
import Flare | |
celsius = number "Celsius" 0.0 | |
convert c = "Fahrenheit: " <> show (c * 9.0 / 5.0 + 32.0) | |
main = runFlare "controls" "output" (map convert celsius) |
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 Main where | |
import Prelude | |
import Data.Int | |
import Data.Array | |
import Data.Maybe | |
import Data.Foldable | |
import Control.Monad.Eff |
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 DeriveFunctor #-} | |
import Data.Monoid | |
import Control.Monad | |
import Control.Applicative | |
-- | An applicative functor `f` over a base type `b` that is "annotated" by a | |
-- | monoidal type `a`. | |
data Ann a f b = Ann a (f b) | |
deriving (Eq, Ord, Show, Functor) |
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 Main where | |
import Prelude | |
import Control.Monad.Eff.Console | |
import Data.Int as I | |
import Data.Complex as C | |
import Math as M | |
class Ring r <= Absolute r where |
OlderNewer