Skip to content
{{ message }}

Instantly share code, notes, and snippets.

🖤

# Cheng ShaoTerrorJack

🖤
Created Jun 13, 2014 — forked from WarrenWeckesser/wavio.py
View wavio.py
 # wavio.py # Author: Warren Weckesser # License: BSD 3-Clause (http://opensource.org/licenses/BSD-3-Clause) import wave import numpy as np def _wav2array(nchannels, sampwidth, data): """data must be the string containing the bytes from the wav file."""
Created Nov 22, 2014
FP-style list in C++11
View gist:a61e9515a0320e7d4a4b
 #include #include template struct _list; template using list = std::shared_ptr<_list>; template struct _list {
Last active Aug 29, 2015
Memoization in haskell
View gist:1fc8f0eb8a8a45f78f14
 fib :: Int -> Integer fib = head . makefib where makefib 0 = [0] makefib 1 = [1,0] makefib n = (head nextfib + head (tail nextfib)):nextfib where nextfib = makefib \$ n - 1 main :: IO () main = print \$ fib 1000
Created Nov 27, 2014
Handwritten packrat parser for trivial integer arithmetic expressions.
View gist:7ea3f024c141ac14425d
 {- Handwritten packrat parser for trivial integer arithmetic expressions. Guarantees O(n) time/space complexity. Rule: Exp <- IntVal / (Exp) / (+ Exp Exp) / (- Exp Exp) / (* Exp Exp) Examples: " 233 ", "( + 42 ((233) ) )", "( (* 42 (+ 1 233)) )". Properly handles whitespaces. "2 33" will not be recognized as 233. -} import Data.Char data Node = Nil | Node {next::Node,char::Char,skipped::Node,result::Result}
Created Dec 13, 2014
Naive PEG parser without memoization
View gist:dacc375125c6ff1a38ff
 import Data.Char newtype Parser a = Parser (String -> [(a,String)]) parse :: Parser a -> String -> ([(a,String)]) parse (Parser p) inp = p inp instance Monad Parser where return val = Parser (\inp -> [(val,inp)]) pa >>= f = Parser (\inp ->
Last active Aug 29, 2015 — forked from chrisdone/AnIntro.md
View AnIntro.md

Basic unit type:

```λ> replTy "()"
() :: ()```

Basic functions:

Created Dec 19, 2014
Call-by-value lambda calculus interpreter (which won't work)
View gist:224b21657cc82f079413
 import qualified Data.Map as Map type Env = Map.Map String Term data Term = VarTerm String | IntTerm Int | BoolTerm Bool | LambdaTerm String Term | AppTerm Term Term
Created Dec 25, 2014
A simple interpreter (that works). Supports ADT/pattern matching. No type system/callcc/macro.
View gist:a413ebced3494e2148a5
 import qualified Data.Map as Map type Env = Map.Map String Val data Exp = ConstExp Val | VarExp String | LambdaExp Pat Exp | LetrecExp [(Pat,Exp)] Exp | IfExp Exp Exp Exp
Created Mar 14, 2015
Web proxies. Keys are domains, values indicate country, software and SSL support.
View webproxy.json
 {"0010freeproxy.info": ["DE", "Glype", false], "0013freeproxy.info": ["DE", "Glype", false], "0021freeproxy.info": ["DE", "Glype", false], "007browser.info": ["US", "Glype", false], "123anonymous.com": ["US", "Glype", false], "1774.info": ["US", "Glype", false], "1agent.info": ["US", "Glype", false], "1block.info": ["US", "Glype", false], "1catch.info": ["US", "Glype", false], "1close.info": ["US", "Glype", false], "1closed.info": ["US", "Glype", false], "1force.info": ["US", "Glype", false], "1good.info": ["US", "Glype", false], "1lazy.info": ["US", "Glype", false], "1mesh.info": ["US", "Glype", false], "1proxy.us": ["US", "PHProxy", true], "1total.info": ["US", "Glype", false], "2999.info": ["US", "Glype", false], "2action.info": ["US", "Glype", false], "2closed.info": ["US", "Glype", false], "2fastsurfer.eu": ["US", "Glype", false], "2fix.info": ["US", "Glype", false], "2g23.com": ["US", "Glype", false], "2g34.com": ["US", "Glype", false], "2gram.info": ["US", "Glype", false], "2insta.info": ["US", "Glype"
Created Mar 25, 2015
some acm data for fun.
View icfp.json
This file has been truncated, but you can view the full file.
 { "event_title": "International Conference on Functional Programming", "event_contents": [ { "conference_title": "Commercial Users of Functional Programming", "conference_contents": [ { "proceeding_title": "CUFP '10:ACM SIGPLAN Commercial Users of Functional Programming", "proceeding_contents": [
You can’t perform that action at this time.