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
(ns brainfuck | |
(:refer-clojure :exclude [replace]) | |
(:require [clojure.string :refer [join replace]])) | |
;;;;;; Parser ;;;;;; | |
(defn- wrap-outer-brackets | |
"Wrap string in square brackets so that its contents are read into a vector | |
by `read-string`." | |
[s] (str \[ s \])) |
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
(defn recogniser | |
"Returns the recogniser function for the grammar `g`." | |
[g] | |
(let [nullable? (nullable g) | |
g (null-free g) | |
init (initial-state (nullable? :S))] | |
(letfn [(consume-token [{:keys [index items] :as state} tok] | |
(loop [processed? #{} | |
items items | |
state (reset-state state)] |
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
require 'set' | |
class AnagramDict | |
include Enumerable | |
def initialize | |
@dict = {} | |
end | |
def put(word) |
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 Undo where | |
data Op = Edit | Undo | Redo | Load | Save deriving (Eq, Show) | |
type Str = [Op] | |
type State = (Int, Int, Int) -- ( Save point, Edit distance, Undo displacement ) | |
valid :: State -> Bool | |
valid (s,e,u) = s >= 0 && e >= 0 && u <= 0 && s <= e && e+u >= 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
#include <iostream> | |
#include <set> | |
using namespace std; | |
typedef pair<int,int> pii; | |
void game(); | |
int main( int , char ** ) | |
{ |
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
class Matrix | |
end |
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
(defvar *prime* (list 2)) | |
(setf count 3) | |
(defun is-prime (n) | |
(dolist (prime-number *prime*) | |
(if (= n 1) (return-from is-prime nil)) | |
(if (= (mod n prime-number) 0) | |
(return-from is-prime nil))) | |
(return-from is-prime t)) |
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
// | |
// mapEngine.m | |
// TestRun | |
// | |
// Created by Ashok Menon on 20/08/2010. | |
// Copyright 2010 __MyCompanyName__. All rights reserved. | |
// | |
#import "mapEngine.h" | |
#import "ImageCache.h" |
NewerOlder