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
;; Totally untested | |
(defn concat [& chans] | |
(let [out (chan)] | |
(go-loop [[ch & more] chans] | |
(when ch | |
(let [val (<! ch)] | |
(if (nil? val) | |
(recur more) | |
(do (>! out val) | |
(recur chans)))))) |
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
ERROR in (some-test) (Reflector.java:432) | |
Uncaught exception, not in assertion. | |
expected: nil | |
actual: | |
at java.util.regex.Matcher.getTextLength(Matcher.java:1233) | |
at java.util.regex.Matcher.reset(Matcher.java:308) | |
at java.util.regex.Matcher.<init>(Matcher.java:228) | |
at java.util.regex.Pattern.matcher(Pattern.java:1088) | |
at clj_stacktrace.utils$re_gsub.invoke(utils.clj:6) | |
at clj_stacktrace.core$clojure_ns.invoke(core.clj:14) |
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
(defproject cljsfoo1 "0.1.0-SNAPSHOT" | |
:plugins [[lein-cljsbuild "0.3.4"] | |
[com.cemerick/austin "0.1.1"]] | |
:dependencies [[org.clojure/clojure "1.5.1"] | |
[org.clojure/clojurescript "0.0-1934"] | |
[ring "1.2.0"] | |
[compojure "1.1.5"] | |
[enlive "1.1.1"]] | |
:source-paths ["src/clj" "src/cljs"] | |
:cljsbuild {:builds |
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
[INFO] Scanning for projects... | |
[INFO] | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Building system-test 0.1.0-SNAPSHOT | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] | |
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ system-test --- | |
[INFO] <<<REDACTED>>> | |
[INFO] +- org.clojure:clojure:jar:1.5.1:compile | |
[INFO] +- <<<REDACTED>>> |
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
#!/usr/bin/env bash | |
# fresh-chrome | |
# | |
# Use this script on OS X to launch a new instance of Google Chrome | |
# with its own empty cache, cookies, and user configuration. | |
# | |
# The first time you run this script, it will launch a new Google | |
# Chrome instance with a permanent user-data directory, which you can | |
# customize below. Perform any initial setup you want to keep on every |
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
(defproject your-project "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.5.1"] | |
[org.clojure/clojurescript "0.0-1845-RC1"]] | |
:repositories {"sonatype-staging" | |
"https://oss.sonatype.org/content/groups/staging/"}) |
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
;; Maze Jam from Lambda Jam 2013, Chicago | |
;; | |
;; by Stuart Sierra, http://stuartsierra.com/ | |
;; | |
;; There are probably bugs in this code. | |
;; | |
;; Copyright (c) 2013 Stuart Sierra | |
;; All rights reserved. | |
;; | |
;; Redistribution and use in source and binary forms, with or without |
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
;; Example implementation of Norvig's Spellchecker in Clojure, | |
;; using core.async | |
;; | |
;; There are probably some bugs in this. | |
;; | |
;; Original problem: https://github.com/ericnormand/spelling-jam | |
;; from Lambda Jam, Chicago, 2013: http://lambdajam.com/ | |
;; | |
;; Clojure core.async introduction: | |
;; http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html |
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
package example; | |
import java.math.BigInteger; | |
public class Factorial { | |
public static BigInteger factorial(final int n) { | |
BigInteger res = BigInteger.valueOf(1L); //build upresult | |
for (int i = n; i > 1; i--) | |
res = res.multiply(BigInteger.valueOf(i)); | |
return res; |
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
;; Demonstration of JVM dead code elimination in Clojure 1.2 and 1.5 | |
;; | |
;; This Clojure script demonstrates some of the effects of dead code | |
;; elimination in the JVM. For unknown reasons, the bytecode produced | |
;; by Clojure 1.2.1 is more susceptible to elimination than the | |
;; bytecode produced by Clojure 1.5.1, making it seem like 1.2.1 is | |
;; faster. But when the code is forced to do real work, the difference | |
;; disappears. | |
;; | |
;; My results with Clojure 1.2.1: |