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 PostfixOperators #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
module Main where | |
import Control.Lens | |
import Control.Monad.State | |
import Prelude hiding ((++)) | |
(++) :: (Num a, MonadState s m) => LensLike' ((,) a) s a -> m 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
warning: Nix search path entry ‘/home/nathan/.nix-defexpr/channels/nixpkgs’ does not exist, ignoring | |
these derivations will be built: | |
/nix/store/7rxarwnalkax5v5fvf1hxrnwql0y3dl9-python2.7-pytest-3.0.7.drv | |
/nix/store/268bwg3nylw2f0v895231msmqxrpknpl-python2.7-Babel-2.3.4.drv | |
/nix/store/g10lnnhpq883v5x7dhrlylqvnpy2377b-python2.7-six-1.10.0.drv | |
/nix/store/1d404igglldx5n0qmdr2m3ccmhz6lw3j-python2.7-unittest2-1.1.0.drv | |
/nix/store/cp6j75wd7wkgi16i23pls9qrdjxc0mkd-python2.7-funcsigs-1.0.2.drv | |
/nix/store/ji8ljdzkqsgvxw5s5kl6fz7h04pzjc68-python2.7-mock-2.0.0.drv | |
/nix/store/5h39f0abz2rbzm97igw8z1b14mhlhmwb-python2.7-apipkg-1.4.drv | |
/nix/store/x77ysrxl9m7vw7bjzj469mvm6v0xsivf-python2.7-execnet-1.4.1.drv |
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 BF where | |
data Token : Set where | |
Plus : Token | |
Minus : Token | |
Less : Token | |
More : Token | |
Period : Token | |
Comma : Token | |
Open : Token |
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
{-# OPTIONS_GHC -fno-warn-orphans #-} | |
module Main where | |
import Data.Treap | |
import Test.QuickCheck | |
instance (Arbitrary h, Arbitrary t, Arbitrary a, Ord h, Ord t) => Arbitrary (Treap h t a) where | |
arbitrary = sized $ \n -> do | |
s <- choose (0, n) |
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
theory PFDS | |
imports Main | |
begin | |
datatype 'a Tree = E | T "'a Tree" 'a "'a Tree" | |
primrec trmax :: "'a ⇒ 'a Tree ⇒ 'a" where | |
"trmax a E = a" | | |
"trmax _ (T _ here right) = trmax here 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
trait Vector { | |
type Direction; | |
fn distance(&self, other : &Self) -> Self; | |
fn neighbour(&self, direction : Self::Direction) -> Self; | |
} | |
trait Grid { | |
type Vector : Vector; | |
fn dimensions(&self) -> Vec<isize>; |
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
pub fn main() { | |
let limit = 1000000; | |
let mut sieve = Vec::with_capacity(limit-2); | |
for _ in (2..limit) { | |
sieve.push(true); | |
} | |
for ix in(0..limit-2) { | |
if sieve[ix] { | |
println!("{}", ix + 2); |
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 Graphics.Element exposing (Element) | |
import Graphics.Collage exposing (collage, toForm, text) | |
import Signal exposing ((<~)) | |
import Time exposing (Time, every) | |
import Date exposing (fromTime, hour, minute, second) | |
import String exposing (padLeft) | |
import Text exposing (Text, fromString, monospace, height) | |
import List exposing (map) | |
main = showTime <~ every Time.second |
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 Nat where | |
newtype Nat = Nat [Nat] deriving (Show, Eq) | |
double :: Nat -> Nat | |
double (Nat []) = Nat [] | |
double (Nat (a : as)) = Nat (succ a : as) | |
half :: Nat -> Nat | |
half (Nat []) = Nat [] |
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 | |
a, b :: String | |
a = "module Main where\n\na, b :: String\na = \"" | |
b = "\"\n\nexpand :: Char -> String\nexpand '\\n' = \"\\\\n\"\nexpand '\"' = \"\\\\\\\"\"\nexpand '\\\\' = \"\\\\\\\\\"\nexpand c = [c]\n\nmain :: IO ()\nmain = do\n putStr a\n putStr $ a >>= expand\n putStr \"\\\"\\nb = \\\"\"\n putStr $ b >>= expand\n putStr b\n" | |
expand :: Char -> String | |
expand '\n' = "\\n" | |
expand '"' = "\\\"" | |
expand '\\' = "\\\\" |