Skip to content

Instantly share code, notes, and snippets.

View LauJensen's full-sized avatar

Lau B. Jensen LauJensen

View GitHub Profile
(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)))))))
;; 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
(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)))
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
(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
(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))
(ns joy.proxytest)
;;== evilbase
(gen-class
:name joy.proxytest.evilbase
:prefix "evilbase-"
:post-init ctor
:methods [[tragedy [] void]]
:impl-ns joy.proxytest)
(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))
(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))
;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]