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 Data.Maybe | |
import Control.Monad.State | |
import Data.Functor ((<$>)) | |
data Env = Env { stack :: [Int] | |
, input :: [String] | |
, result :: Result } | |
type Eval = State Env | |
data Op = Push Int | Disp | Add | Sub | Mul | Div deriving Show |
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 Control.Monad | |
import System.IO | |
import System.IO.Unsafe | |
ifte :: Monad m => m Bool -> m a -> m a -> m a | |
ifte c t e = c >>= \b -> if b then t else e | |
getLinesI :: IO [String] | |
getLinesI = unsafeInterleaveIO $ ifte isEOF (return []) (liftM2 (:) getLine getLinesI) |
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 Control.Applicative | |
data Expr = Var String | |
| Abs String Expr | |
| App Expr Expr | |
instance Show Expr where | |
show (Var v) = v | |
show (Abs v e) = "(\\" ++ v ++ " -> " ++ (show e) ++ ")" |
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 Data.Char | |
import Data.Word | |
import Data.List | |
import Data.Function | |
import Data.Array.Unboxed | |
import Data.Array.IO | |
import Control.Applicative | |
import Text.Parsec hiding ((<|>), many) | |
import Text.Parsec.String | |
import System.IO |
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 Control.Monad | |
import Control.Applicative | |
import System.Random | |
randomRnIO :: Random a => Int -> (a, a) -> IO [a] | |
randomRnIO n r = sequence $ replicate n (randomRIO r) | |
points :: IO [(Int, Int)] | |
points = liftM2 zip (randomRnIO 10 (0, 100)) (randomRnIO 10 (0, 100)) |
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 Data.List | |
import Data.Maybe | |
import Data.Graph.Inductive.Graph | |
import Data.Graph.Inductive.Basic | |
import Data.Graph.Inductive.Tree | |
import Data.Graph.Inductive.Internal.RootPath | |
import Data.Graph.Inductive.Query.DFS | |
import Data.Graph.Inductive.Query.MST | |
import Control.Applicative | |
import Control.Monad |
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 as M | |
import XMonad | |
import qualified XMonad.StackSet as W | |
import XMonad.Actions.WindowGo | |
import XMonad.Actions.CycleWS | |
import XMonad.Hooks.ManageDocks | |
import XMonad.Hooks.EwmhDesktops | |
import XMonad.Layout |
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
(when (require 'cl-indent-patches nil t) | |
(setq lisp-indent-function | |
(lambda (&rest args) | |
(apply (if (memq major-mode '(emacs-lisp-mode lisp-interaction-mode)) | |
'lisp-indent-function | |
'common-lisp-indent-function) | |
args)))) |
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
(defpackage :brainfuck (:use :cl)) | |
(in-package :brainfuck) | |
(defun string->brainfuck (source) | |
(let* ((fragments | |
(map 'list | |
(lambda (c) | |
(case c | |
(#\> "(incptr 1)") |
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
type r = { name : string; age : int } with value | |
type t = Foo of r | Bar of int * string with value | |
let _ = | |
let t = Foo { name = "Foo"; age = 100 } in | |
print_endline (Value.to_string (value_of_t t)) | |
(* => E/t/2/<Foo;E/r/2/{name:S(Foo);age:I(100)}> *) |
OlderNewer