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 RatPoly | |
( RatPoly(Constant) | |
, x | |
, (//) | |
, degree | |
, eval | |
, polyDivMod | |
, polyDiv | |
, polyMod | |
, polyGcd |
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 QuantumBogoSort (sort, sortBy) where | |
import Data.List (permutations) | |
import Control.Monad (guard) | |
-- Check if a list is sorted | |
sortedBy :: (a -> a -> Ordering) -> [a] -> Bool | |
sortedBy _ [] = True | |
sortedBy _ [_] = True | |
sortedBy c (x:y:xs) = c x y <= EQ && sortedBy c (y:xs) |
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 Poly (Field, inverse, (//), Poly(C), x, degree, leading, polyDivMod, | |
polyDiv, polyMod, polyGcd, polyGcdW) where | |
import Control.Monad.Trans.Writer (Writer, tell) | |
-- Typeclass for Algebraic Fields | |
class Num a => Field a where | |
(//) :: a -> a -> a | |
a // b = a * inverse b | |
inverse :: a -> 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
import qualified Data.Map.Lazy as Map | |
import Data.Map.Lazy (Map) | |
import Data.List (unfoldr) | |
-- Data needed to extend the sequence | |
data State = State { | |
history :: Map Integer Integer, -- When each number except the current was seen | |
position :: Integer, -- Current position | |
curr :: Integer -- Current value | |
} |
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
> let proplist = ((\x -> conj (prop $ 'a':show x) (prop $ 'b':show x)) <$> [0..2]) | |
> putStr . unlines $ fancyRender id <$> proplist | |
a0 ∧ b0 | |
a1 ∧ b1 | |
a2 ∧ b2 | |
> putStrLn $ fancyRender (either (('t':).show) id) $ disjSmall proplist | |
(¬t0 ∨ a0) ∧ (¬t0 ∨ b0) ∧ (¬t1 ∨ a1) ∧ (¬t1 ∨ b1) ∧ (¬t2 ∨ a2) ∧ (¬t2 ∨ b2) ∧ (t0 ∨ t1 ∨ t2) | |
> putStrLn $ fancyRender id $ foldl1 disjBig proplist | |
(a0 ∨ a1 ∨ a2) ∧ (a0 ∨ a1 ∨ b2) ∧ (a0 ∨ a2 ∨ b1) ∧ (a0 ∨ b1 ∨ b2) ∧ (a1 ∨ a2 ∨ b0) ∧ (a1 ∨ b0 ∨ b2) ∧ (a2 ∨ b0 ∨ b1) ∧ (b0 ∨ b1 ∨ b2) |
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 RankNTypes #-} | |
module UnionFind ( | |
Getter, | |
Setter, | |
UnionFind, | |
UnionFindS, | |
new, | |
find, | |
union, |
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
LOOP FOREVER | |
+[- | |
LOAD FIRST INPUT IN POS 0 & SECOND IN POS 1 | |
,>,< | |
WHILE POS 0 ISNT 0 | |
[ | |
MOVE TO POS 1 & COPY VALUE TO POS 3 & 4 | |
>[->>+>+>+<<<<]>>>>[-<<<<+>>>>]<<<< | |
MOVE TO POS 3 | |
>> |
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
WHILE INPUT IS NONZERO | |
,[ | |
MOVE TO LEFT ELEMENT | |
<< | |
WHILE LEFT ELEMENT EXISTS | |
[ | |
ORDER POS 0 AND POS 2 WITH SMALLEST ON RIGHT | |
USING POS 0 & 1 & 2 & 3 & 5 & 7 | |
WHILE POS 0 ISNT 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
SET POS 0 TO 2 | |
++ | |
WHILE POS 0 ISNT 0 | |
[ | |
SET POS 1 TO 2 | |
>++< | |
SET POS 2 TO POS 0 MINUS POS 1 | |
[->>+>+<<<]>>>[-<<<+>>>]<<[->->+<<]>>[-<<+>>]<<< | |
WHILE POS 1 ISNT POS 0 (POS 2 ISNT 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
{-# LANGUAGE TypeOperators, ExplicitNamespaces #-} | |
module Rates ( | |
Rate(..), | |
(&*), | |
rev, | |
(&/), | |
RatRate, | |
type (//) | |
) where |