Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

hallo

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