Skip to content
Browse files

hallo

  • Loading branch information...
1 parent c9ec87b commit 3df2e5366832c499a97af9fa9df9d530a1954f23 Alan Dipert committed Feb 22, 2010
Showing with 10 additions and 8 deletions.
  1. +4 −2 README
  2. +2 −2 src/org/dipert/utils/math.clj
  3. +4 −4 test/org/dipert/utils/test/math.clj
View
6 README
@@ -1,6 +1,8 @@
-# alan-utils
+# close personal clj functions of alan
-Stuff for doing things.
+Stuff I made for doing things, mostly mathy things, like a strton(3)
+clone. Also, check out tests/math.clj for a cool macro that lets you
+test private functions in a different namespace.
## License
View
4 src/org/dipert/utils/math.clj
@@ -1,5 +1,5 @@
(ns org.dipert.utils.math
- "These are some math-related functions I've found useful."
+ "These are some math-related functions I've found useful. 8-)"
(:use (clojure.contrib math)))
(defn- powers-of [n]
@@ -21,7 +21,7 @@
vals (range 0 (inc (count syms)))]
(zipmap syms vals)))
-(defn- prep-str [s base]
+(defn- prep-str [#^String s base]
"Maps characters to values, ignoring unrecognized characters."
(let [charmap (syms-vals base)]
;; Convert to upper case, filter out unknown chars, map to values
View
8 test/org/dipert/utils/test/math.clj
@@ -7,7 +7,7 @@
`(let ~(reduce #(conj %1 %2 `(ns-resolve '~ns '~%2)) [] fns)
~@tests))
-(with-private-fns [org.dipert.alan.utils.math [powers-of syms-vals char-range prep-str]]
+(with-private-fns [org.dipert.utils.math [powers-of syms-vals char-range prep-str]]
(deftest test-powers-of
(let [powers-2 (powers-of 2)
@@ -35,8 +35,8 @@
(deftest test-strton
(is (= 3764 (strton "0111010110100" 2)) "The binary string should equal 3764 in decimal")
(is (= 3764 (strton "7264" 8)) "The octal string should equal 3764 in decimal")
- (is (= 3764 (strton "EB4" 16)) "The hex string EB4 should equal 3764 in decimal")
- (is (= 3764 (strton "eb4" 16)) "The hex string eb4 should equal 3764 in decimal")
+ (is (= 3764 (strton "EB4" 16)) "The hex string should equal 3764 in decimal")
+ (is (= 3764 (strton "eb4" 16)) "The hex string should equal 3764 in decimal")
(is (= 3764 (strton "zeb4q" 16)) "The corrupt hex string should equal 3764 in decimal")
(is (= 3764 (strton "0xEB4" 16)) "The hex string with a preceding 0x should equal 3764 in decimal")
- (is (= 717 (strton "5a2" 11))) "The undecimal string should equal 717 in decimal")
+ (is (= 717 (strton "5a2" 11))) "The undecimal string should equal 717 in decimal")

0 comments on commit 3df2e53

Please sign in to comment.
Something went wrong with that request. Please try again.