Skip to content

Instantly share code, notes, and snippets.

View billdozr's full-sized avatar

Alen Ribic billdozr

View GitHub Profile
/**Below are 2 implementations of the same function for checking whether a binary tree is sorted. isSortedA was made by myself as an answer to an exercise in FP in Scala. isSortedB was found on github as an answer to the same exercise. I assume isSortedB is better, but can anyone tell me why (other than the fact that I left out @annotation.tailrec).*/
def isSortedA[A](as: Array[A], gt: (A, A) => Boolean): Boolean = {
def go(n: Int): Boolean = {
if (n <= 0) true
else if (!gt(as(n), as(n-1)))false
else go(n-1)
}
go(as.length-1)
}
@billdozr
billdozr / README.md
Created October 12, 2013 17:33 — forked from nikcub/README.md
@billdozr
billdozr / jquerytest.cljs
Created July 25, 2011 23:32 — forked from ryancrum/jquerytest.cljs
How to use jQuery from ClojureScript
(ns jquerytest.core)
(def jquery (js* "$"))
(jquery
(fn []
(-> (jquery "div.meat")
(.html "This is a test.")
(.append "<div>Look here!</div>"))))