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 knapsack_count | |
[sack space] | |
(if (or (empty? sack) (< space 0)) | |
0 | |
(if (= space 0) | |
1 | |
(+ | |
(knapsack_count (next sack) space) | |
(knapsack_count sack (- space (first sack))))))) |
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
;; put test.jpg in root/public/test.jpg | |
(defroutes app | |
(GET "/" [] "Hello, world") | |
(ANY "*" [] (redirect "/"))) | |
(run-jetty (-> app (wrap-file "public")) | |
{:port 8080}) | |
;; access //localhost:8080/public/test.jpg |
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 render [#^Graphics g scene w h #^Integer scale] | |
(do-board [w h1] | |
(.setColor g (org.newdawn.slick.Color. (aget! scene i (+ h1 j)))) | |
(.fillRect g (* scale i) (* scale (+ h1 j)) scale scale))) | |
(defn render [#^Graphics g scene w h #^Integer scale] | |
(let [h1 (int (/ h 2)) | |
r1 (future | |
(do-board [w h1] | |
(.setColor g (org.newdawn.slick.Color. (aget! scene i j))) |
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 sort(xs: Array[Int]) { | |
def swap(i: Int, j: Int) { | |
val t = xs(i); xs(i) = xs(j); xs(j) = t | |
} | |
def sort1(l: Int, r: Int) { | |
val pivot = xs((l + r) / 2) | |
var i = l; var j = r | |
while (i <= j) { | |
while (xs(i) < pivot) i += 1 | |
while (xs(j) > pivot) j -= 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
(ns p.pulp | |
(:import (pulpcore.animation Easing Timeline) | |
(pulpcore.animation.event RemoveSpriteEvent) | |
(pulpcore.image BlendMode CoreImage CoreFont) | |
(pulpcore Input Stage) | |
(pulpcore.math CoreMath) | |
(pulpcore.scene Scene2D) | |
(pulpcore.sprite FilledSprite Group ImageSprite Sprite Label)) | |
(:gen-class | |
:extends pulpcore.scene.Scene2D |
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 tunnel | |
(:import (pulpcore.animation Easing Timeline) | |
(pulpcore.animation.event RemoveSpriteEvent) | |
(pulpcore.image BlendMode CoreImage CoreFont) | |
(pulpcore Input Stage) | |
(pulpcore.math CoreMath) | |
(pulpcore.scene Scene2D) | |
(pulpcore.sprite FilledSprite Group ImageSprite Sprite Label)) | |
(:gen-class)) |
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 joy.proxytest) | |
;;== evilbase | |
(gen-class | |
:name joy.proxytest.evilbase | |
:prefix "evilbase-" | |
:post-init ctor | |
:methods [[tragedy [] void]] | |
:impl-ns joy.proxytest) |
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 pulp | |
(:import (pulpcore.animation Easing Timeline) | |
(pulpcore.animation.event RemoveSpriteEvent) | |
(pulpcore.image BlendMode CoreImage CoreFont) | |
(pulpcore Input Stage) | |
(pulpcore.math CoreMath) | |
(pulpcore.scene Scene2D) | |
(pulpcore.sprite FilledSprite Group ImageSprite Sprite Label)) | |
(:gen-class :extends pulpcore.scene.Scene2D :main true)) |
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 pulp | |
(:import (pulpcore.animation Easing Timeline) | |
(pulpcore.animation.event RemoveSpriteEvent) | |
(pulpcore.image BlendMode CoreImage CoreFont) | |
(pulpcore Input Stage) | |
(pulpcore.math CoreMath) | |
(pulpcore.scene Scene2D) | |
(pulpcore.sprite FilledSprite Group ImageSprite Sprite Label)) | |
(:gen-class :extends pulpcore.scene.Scene2D)) |
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
;sample use idea: | |
(defn mapx | |
"Returns a lazy sequence consisting of the result of applying f to the | |
set of first items of each coll, followed by applying f to the set | |
of second items in each coll, until any one of the colls is | |
exhausted. Any remaining items in other colls are ignored. Function | |
f should accept number-of-colls arguments." | |
[f coll] | |
(gen-iter iter [f seq-cell] |