Skip to content

Instantly share code, notes, and snippets.

View zearen's full-sized avatar

Zearen Wover zearen

View GitHub Profile
@zearen
zearen / prime-climb-write-dot.rs
Created February 14, 2020 02:22
A little script I wrote to generate a transition map for a single pawn playing PrimeClimb
extern crate petgraph;
use petgraph::graph::{Graph, NodeIndex};
use std::fmt;
use std::ops::Range;
use std::slice::Iter;
use std::io::Write;
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
enum Op { Add, Sub, Mul, Div }

Keybase proof

I hereby claim:

  • I am zearen on github.
  • I am zearen (https://keybase.io/zearen) on keybase.
  • I have a public key whose fingerprint is 1623 CE54 3275 5206 C3AB 0E25 4E71 FD0C 338A 7560

To claim this, I am signing this object:

@zearen
zearen / QSemR.hs
Created September 8, 2013 17:20
A sketch of a reverse semaphore for Haskell
module Control.Concurrent.QSemR
( newQSemR
, bracketQSemR
, whenEmptyQSemR
) where
import Control.Exception (bracket)
import Control.Concurrent.MVar
type QSemR = (MVar (), MVar Int)
@zearen
zearen / PonjoLojbo.hs
Created March 23, 2013 07:52
An experimental, likely insultling, katakana/hiragana orthography for Lojban
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE DeriveDataTypeable #-}
import qualified Data.Map as Map
import Data.Maybe
import Text.Parsec
import System.Console.CmdArgs
type Map = Map.Map
@zearen
zearen / SepiidapusBreeding.hs
Created March 19, 2013 03:31
Sepiidapus breeding tools
{-# LANGUAGE TemplateHaskell #-}
module SepiidapusBreeding where
import Data.List
import Data.Lens.Common
import Data.Lens.Template
data Karyo
= I
@zearen
zearen / camxes.py
Created March 10, 2013 06:56
A beginning of a python interface to camxes
from subprocess import Popen, PIPE
class ParseUtil():
def __init__(self, resp):
self.resp = resp
self.pos = 0
def at(self):
return self.resp[self.pos]
So I was watching an MIT lecture on algorithms, and they were talking about
the quicksort, so I decided I should revisit it in haskell now that I have
a little more experience. The common example you see has issues with repeated
work. I attempt to minimize this me avoiding list concatenation and
using a partition instead.
I used literate Haskell because I plan to add better annotations later.
> {-# LANGUAGE PatternGuards #-}
> module Quicksort where
@zearen
zearen / MSPAMorseCode.hs
Created March 8, 2012 20:52
Parsing Morse code with haskell
data MorseNode = MorseNode
{ mnVal :: Char
, mnDit :: Maybe MorseNode
, mnDah :: Maybe MorseNode
}
deriving (Eq)
instance Show MorseNode where
showsPrec _ (MorseNode val dit dah) = ('\'':) . (val:) . ("<."++)
. (maybe (' ':) shows $ dit) . ('-':) . (maybe (' ':) shows $ dah)
@zearen
zearen / JSONParser.hs
Created January 28, 2012 04:00
A simple haskell demonstation showing parsing JSON with Parsec
{-
Zachary Weaver <zaw6@pitt.edu>
JSONParser.hs
Version 0.1.1
A simple example of parsing JSON with Parsec in haskell. Note that
since the primary point of this excersize is demonstration,
Text.Parsec.Token was avoided to expose more of the grammar. Also,
complicated optimizations and shorcuts were avoided (mostly).