Skip to content

Instantly share code, notes, and snippets.

@xixixao
xixixao / Switch
Created April 3, 2013 08:59
Clojure vs Coffee
#(defn parting
# "returns a String parting in a given language"
# ([] (parting "World"))
# ([name] (parting name "en"))
# ([name language]
# (condp = language
# "en" (str "Goodbye, " name)
# "es" (str "Adios, " name)
# (throw (IllegalArgumentException.
# (str "unsupported language " language))))))
@xixixao
xixixao / gist:e8b74ff74e98bdd0c137
Created March 13, 2015 11:55
LSystems in Shem
Rules (type (Map Char String))
System (record angle: Num base: (List Char) rules: Rules)
tree (fn [angle] (System angle
{\M}
(Map
\M "N[-M][+M][NM]"
\N "NN"
\[ "["
\] "]"
+ (macro [x y]
(: (Fn Num Num Num))
(Js.binary "+" x y))
- (macro [what from]
(: (Fn Num Num Num))
(Js.binary "-" from what))
* (macro [x y]
(: (Fn Num Num Num))
{task, watch, serve} = require 'gump'
bower = require 'gulp-bower-files'
flatten = require 'gulp-flatten'
stylus = require 'gulp-stylus'
jade = require 'gulp-jade'
clean = require 'gulp-clean'
task 'default',
'clean'
-> watch 'sources'
render: ->
_.table _,
_.thead _,
_.tr _,
_.th "BV"
_.th "x1"
_.th "x2"
_.th "x3"
_.th "x4"
_.th "RHS"
@xixixao
xixixao / Simplex Algorithm.coffee
Last active August 29, 2015 13:57
OR operations
#I = [5, 6, 7]
#matrix = [
# [1, 10, -57, -9, -24, 0, 0, 0, 0]
# [0, 0.5, -5.5, -2.5, 9, 1, 0, 0, 0]
# [0, 0.5, -1.5, -0.5, 1, 0, 1, 0, 0]
# [0, 1, 0, 0, 0, 0, 0, 1, 1]
#]
I = [4, 7, 6, 8]
matrix = [
@xixixao
xixixao / -
Created March 10, 2014 14:37
I = [5, 6, 7]
matrix = [
[1, 10, -57, -9, -24, 0, 0, 0, 0]
[0, 0.5, -5.5, -2.5, 9, 1, 0, 0, 0]
[0, 0.5, -1.5, -0.5, 1, 0, 1, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 1, 1]
]
max = (array) ->
@xixixao
xixixao / -
Created February 14, 2014 18:38
I = [5, 6, 7]
matrix = [
[1, 10, -57, -9, -24, 0, 0, 0, 0]
[0, 0.5, -5.5, -2.5, 9, 1, 0, 0, 0]
[0, 0.5, -1.5, -0.5, 1, 0, 1, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 1, 1]
]
max = (array) ->
@xixixao
xixixao / -
Created February 14, 2014 17:54
I = [5, 6, 7]
matrix = [
[1, 10, -57, -9, -24, 0, 0, 0, 0]
[0, 0.5, -5.5, -2.5, 9, 1, 0, 0, 0]
[0, 0.5, -1.5, -0.5, 1, 0, 1, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 1, 1]
]
max = (array) ->