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
sc () { | |
if [[ -f ./script/rails ]] | |
rails c $@ | |
else | |
./script/console $@ | |
fi | |
} |
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
sc () { | |
if [[ -f ./script/rails ]] | |
then | |
rails c $@ | |
else | |
./script/console $@ | |
fi | |
} |
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 fib | |
([] (concat [0 1] (fib 0 1))) | |
([a b] (lazy-cons (+ a b) (fib b (+ a b))))) | |
user> (take 20 (fib)) | |
(0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181) |
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
Exception in thread "main" java.lang.Exception: Unable to resolve symbol: re-gsub in this context (palindromes.clj:27) | |
at clojure.lang.Compiler.analyze(Compiler.java:5205) | |
at clojure.lang.Compiler.analyze(Compiler.java:5151) | |
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3036) | |
at clojure.lang.Compiler.analyzeSeq(Compiler.java:5371) | |
at clojure.lang.Compiler.analyze(Compiler.java:5190) | |
at clojure.lang.Compiler.analyze(Compiler.java:5151) | |
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:4670) | |
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:4328) |
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 testing | |
(:require [clojure.string :as str])) | |
(defn sanitize [n] | |
(str/replace #"[^a-z]" "" (.toLowerCase n)) | |
) | |
(print (sanitize "abba")) | |
;; output is "abba[abba^abba-abba]abba" |
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 palindromes | |
(:require [clojure.string :as str])) | |
(def text | |
(str "I'll just type in some example text here and embed a little | |
palindrome - A man, a plan, a canal, Panama! - I expect that will be | |
the longest palindrome found in this text. | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | |
Integer volutpat lorem imperdiet ante bibendum ullamcorper. Mauris |
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
;; Exception in thread "main" java.lang.UnsupportedOperationException: Can only recur from tail position (test.clj:6) | |
(defn rev [data] | |
(loop [data data, product ()] | |
(if (empty? data) | |
product | |
((conj product (first data)) | |
(recur (rest data) product))))) | |
(print (rev '(1 2 3 4 5))) |
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 happy?(x) | |
seen = [] | |
while !(seen.include?(x)) | |
seen << x | |
x = x.to_s.chars.inject(0) { |sum, i| sum += (i.to_i * i.to_i) } | |
#puts "iteration: #{x}\n" | |
return true if x == 1 | |
end | |
return false |
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
PragPub, the free monthly electronic magazine for software | |
developers from The Pragmatic Programmers, will be publishing a | |
special Clojure issue in July, and we're looking for articles. | |
I'm committed to sourcing at least one article in that issue | |
from one of the many active Clojure user groups around the | |
world. I've been a believer in developer user groups since the | |
1980s when I was editing Dr. Dobb's Journal, inspired by Dennis | |
Allison's image of a community of developers standing on each | |
other's shoulders, and I know there are some great ideas out |
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
diff --git a/array.c b/array.c | |
index b1616c5..16326fc 100644 | |
--- a/array.c | |
+++ b/array.c | |
@@ -302,7 +302,7 @@ ary_alloc(VALUE klass) | |
return (VALUE)ary; | |
} | |
-static VALUE | |
+VALUE |
OlderNewer