Skip to content

Instantly share code, notes, and snippets.

View notcome's full-sized avatar

Minsheng Liu notcome

View GitHub Profile
% http://www.tutorialspoint.com/execute_matlab_online.php
n = 8;
N = zeros(n+1);
c = linspace(1,n+1,n+1);
for i=1:n+1
for j=1:n+1
N(i,j)= ((j-1)/n)^(i-1);
end
c(i)=1/c(i);
end
@notcome
notcome / sequent_calculus.hs
Created June 27, 2015 03:14
A naïve implementation of sequent calculus.
module Calculus where
import Control.Monad (liftM2)
import Data.List (sort, permutations, nub)
import Data.Char (chr)
import Debug.Trace
data Formula = Formula Int
| Not Formula
@notcome
notcome / FixedList.hs
Created June 8, 2015 03:43
Static list with fixed length
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE FlexibleInstances #-}
@notcome
notcome / kmp.hs
Created May 26, 2015 14:08
KMP by some guy on 知乎 with “tying the knot” technique
{-# LANGUAGE NoMonomorphismRestriction #-}
module KMP3 (buildKMP , matchKMP , State) where
data State a =
State (State a) (State a) a -- State next fail char
| Aux (State a) -- Aux next
| Finish (State a) -- Finish fail
nextOf :: Eq a => State a -> a -> State a
@notcome
notcome / CLL.hs
Created April 22, 2015 16:43
陆陆的姓名生成器
import Control.Monad.State
import System.Random
type Range = (Int, Int) -> Int
rangify :: Int -> Range
rangify x (lo, hi) = x `mod` (hi - lo + 1) + lo
getRandomsR :: RandomGen g => State g [Range]
getRandomsR = map rangify . randoms <$> state split
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad.Writer
listify :: Writer [a] () -> [a]
listify = execWriter
item x = tell [x]
main = do
@notcome
notcome / clean-xcode-cahce.sh
Created March 9, 2015 10:59
Clean Xcode Cache of Plug-Ins
rm -f /private/var/folders/*/*/*/com.apple.DeveloperTools/*/Xcode/PlugInCache-Debug.xcplugincache
rm -rf /private/var/folders/*/*/*/com.apple.DeveloperTools/*/Xcode/PlugInCache.xcplugincache
@notcome
notcome / demo.hs
Created March 2, 2015 15:32
Human readable Haskell representation for "Quick Quote"
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE UnicodeSyntax #-}
import Prelude hiding (putStrLn)
import Data.Text.Lazy.IO (putStrLn)
import Control.Monad.Writer
-- Monoid Instance --
@notcome
notcome / trim-and-spacing.html
Created February 23, 2015 10:07
标点挤压,汉字与西文的空格
<style>
html {
font-family: Helvetica;
}
body {
width: 30em;
margin: auto;
}
p {
width: 581px;
@notcome
notcome / sb.hs
Created February 21, 2015 08:30
simplified boomerang in Haskell and PureScript
module Main where
import Prelude hiding (id, (.))
import Control.Category
import Control.Monad ((>=>))
import Data.List (stripPrefix)
type URL = [String]
type Route a = (URL, a)