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
(def opening-brackets "({[<") | |
(def closing-brackets ")}]>") | |
(def brackets (reduce #(apply assoc %1 %2) {} | |
(map vector opening-brackets closing-brackets))) | |
(defn- check-aux [[x & xs] stack] | |
(if x | |
(cond (some #{x} opening-brackets) (recur xs (conj stack (brackets x))) | |
(some #{x} closing-brackets) (if (= x (peek stack)) | |
(recur xs (pop stack)) |
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
(def brackets (zipmap "([{<" ")]}>")) | |
(def opening-brackets (set (keys brackets))) | |
(def closing-brackets (set (vals brackets))) | |
(defn- check-aux [[x & xs] stack] | |
(if x | |
(cond (opening-brackets x) (recur xs (conj stack (brackets x))) | |
(closing-brackets x) (if (= x (peek stack)) | |
(recur xs (pop stack)) | |
false) |
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
>>> s1 = set(["a", "b", "c"]) | |
>>> s2 = set(["a"]) | |
>>> s1 - s2 | |
set(['c', 'b']) |
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
{21:33}[vince@vincent: prog/clojure]% clj slowdemo.clj | |
get-byte | |
"Elapsed time: 202.54176 msecs" | |
get-short | |
"Elapsed time: 110.68448 msecs" | |
{21:33}[vince@vincent: prog/clojure]% clj slowdemo.clj | |
Reflection warning, line: 9 - call to and can't be resolved. | |
Reflection warning, line: 14 - call to and can't be resolved. | |
get-byte |
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
user> (def rep (unpack (File. "/home/vince/prog/python/pyreplib/misc/sea_savior.rep"))) | |
#'user/rep | |
user> (unit-distribution (get-in rep [:players 0 :actions])) | |
{"Firebat" 34, "Dropship" 3, "Science Vessel" 43, "Medic" 48, "Marine" 599, "SCV" 82} | |
user> (unit-distribution (get-in rep [:players 1 :actions])) | |
{"Ultralisk" 95, "Defiler" 32, "Scourge" 25, "Mutalisk" 8, "Zergling" 179, "Overlord" 35, "Drone" 158} | |
user> (action-distribution (get-in rep [:players 1 :actions])) |
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
/* | |
* Compare two cards and return: | |
* < 0 if a is smaller than b | |
* 0 if a is equal to b | |
* > 0 if a is greater than b | |
*/ | |
int CardCompare(const Card* a, const Card* b) { | |
if (a == NULL) | |
return 1; | |
if (b == NULL) |
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 'a tree = | |
| Empty | |
| Node of ('a * 'a tree * 'a tree) | |
let rec walk_tree f tree = | |
match tree with | |
| Empty -> () | |
| Node (x, left, right) -> | |
f x; | |
walk_tree f left; |
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 'a tree = | |
| Empty | |
| Node of ('a * 'a tree * 'a tree) | |
let rec walk_tree f tree = | |
match tree with | |
| Empty -> () | |
| Node (x, left, right) -> | |
f x; | |
walk_tree f left; |
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
;; init.el | |
;; Vincent Foley - vfoley@gmail.com | |
(require 'cl) | |
(defmacro when-package-installed (package-name &rest body) | |
`(if (package-installed-p ,package-name) | |
(progn ,@body) | |
(warn "package %s is not installed" ,package-name))) |
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
.text | |
_main: | |
cmp %ebx, %ecx | |
mov $1, %eax | |
je equal | |
mov $0, %eax | |
equal: | |
ret | |
OlderNewer