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
SPECIFICATIONS FOR DCPU/THRUSTER INTERFACE DRAFT 0.01 | |
Name: UTI0001 - Universal Thruster Interface | |
ID: BFEC9661, verson: 0x0001 | |
Manufacture: 0 (n/a) | |
0: NO_OF_SPEEDS | |
Writes the number of available speeds to the C register. | |
1: SET_SPEED | |
Reads the B register, and attempts to set the thruster to the specified |
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
use std::iter::Unfold; | |
use std::os::args; | |
fn next(arg : &mut (int, int)) -> Option<int> { | |
let (lo, hi) = *arg; | |
*arg = (hi, lo + hi); | |
Some(lo) | |
} | |
fn main() { |
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
,[>+>+<<-] input digit and copy it into A(2) and A(3) | |
>> | |
[>,----------] input rest of line subtracting 10 from each character to check for EOL | |
++++++++++<[++++++++++<] re add the 10s | |
Note that this also adds 10s to the two copies of the digit and sets the location to the beginning of the tape | |
>---------------------------------------------------------- subtract 58 from the first copy of the digit so it is its number now | |
>----------< subtract 10 from the other copy of the digit so it is what it should be then go back to the first digit where the fun happens | |
[>[.>]<[<]>-] print the string then decrement the number until the number reaches zero |
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 '\\' = "\\\\" |
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
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
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
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
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
{-# 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) |
OlderNewer