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 prime? [n] | |
(cond (= n 2) true | |
(= n 3) true | |
:else | |
(not-any? #(zero? (mod n %))(range (int (Math/sqrt n)) n)))) | |
(def my-primes (filter prime? (iterate inc 2))) | |
(defn update-or-insert [m k f d] | |
(if (contains? m k) |
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 force-set [n] | |
(if (set? n) n | |
(conj #{} n))) | |
(merge-with (fn [r l] (conj (force-set r) l)) {:a 1 :b 2} {:a 1 :b 3}) | |
=> {:a #{1}, :b #{2 3}} |
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 siever2 [to-sieve sieved end] | |
(if (empty? to-sieve) sieved | |
(let [f (first to-sieve) | |
r (rest to-sieve)] | |
(if (> f (Math/sqrt end)) | |
(into sieved to-sieve) | |
(siever2 (remove #(zero? (mod % f)) r) | |
(conj sieved f) | |
end))))) | |
(dotrace [siever2] (siever2 (range 2 32) [] 31)) |
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
public class ButtonOperator extends Button { | |
/*public ButtonOperator(final CalculatorController controller, | |
final AbstractOperator op) { | |
super(op.label); | |
this.addClickHandler(new ClickHandler() { | |
@Override | |
public void onClick(ClickEvent event) { | |
controller.processOperator(op); |
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
(defroutes handler | |
(GET "/" [] | |
(html | |
(doctype :xhtml-strict) | |
(xhtml-tag "en" | |
[:head | |
[:meta {:http-equiv "Content-type" | |
:content "text/html; charset=utf-8"}] | |
[:title "adder"] | |
[:link {:href "/adder.css" :rel "stylesheet" :type "text/css"}]] |
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
(defroutes handler | |
(GET "/" [] | |
(html | |
(doctype :xhtml-strict) | |
(xhtml-tag "en" | |
[:head | |
[:meta {:http-equiv "Content-type" | |
:content "text/html; charset=utf-8"}] | |
[:title "test"]] | |
[:body "\u05d2"])))) |
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 guard [pred & args] | |
(if (apply pred args) args nil)) | |
(def guard-> (partial guard >)) | |
(guard-> 6 5) ; => (6 5) | |
(guard-> 5 6) ; => nil |
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
D:\Mijn documenten\My Dropbox\dev\clojure-projects\hebrewajax>git push heroku ma | |
ster | |
Counting objects: 32, done. | |
Delta compression using up to 2 threads. | |
Compressing objects: 100% (22/22), done. | |
Writing objects: 100% (32/32), 35.64 KiB, done. | |
Total 32 (delta 5), reused 0 (delta 0) | |
-----> Heroku receiving push | |
-----> Clojure app detected |
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
;; Dit programma maakt gebruik van het Round Robin Tournament Scheduling Algoritme | |
;; Zoals beschreven op http://en.wikipedia.org/wiki/Round-robin_tournament | |
;; Eerst volgen er wat losse fragmenten Clojure-code om het een en ander toe te lichten | |
;; De eigenlijke oplossing bestaat uit de functies turn-around en solutions | |
(def students (shuffle (range 100))) ; students is een lijst van de getallen 0 t/m 99, geshuffeld | |
(def first-half (take (/ (count students) 2) students)) ; de eerste helft van de lijst studenten | |
(def second-half (reverse (drop (/ (count students) 2) students))) ; de tweede helft | |
;;eventueel ook te schrijven met behulp van de threading macro -> als: | |
(def second-half (-> (count students) (/ 2) (drop students) reverse)) |
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 twitter-api-test.followers-minus-friends | |
(:use | |
[twitter.api.restful :only [show-followers show-friends lookup-users]] | |
[clojure.set :only [difference]]) | |
(:require [clojure.string :as string])) | |
(defn vector-to-comma-separated [vector] | |
(string/join "," vector)) | |
(defn userinfos [idset] |
OlderNewer