Open seako opened 7 years ago
this seems like it could grow into quite a few functions.
E.g., (defn conj-71 [coll] (conj coll seventy-one))
, etc.
I'm not sure how I feel about that.
Performance tests indicate that a dedicated function for multiplying 71 would be useful.
user> (defn multiply-by-seventy-one
^long
[^long x]
(* x 71))
#'user/multiply-by-seventy-one
user> (time (dotimes [i 1000000]
(* i seventy-one)))
"Elapsed time: 43.733091 msecs"
nil
user> (time (dotimes [i 1000000]
(multiply-by-seventy-one i)))
"Elapsed time: 31.528017 msecs"
nil
Alternatively, rather than trying to individually solve all possible API needs regarding 71, we could add a universal macro ->71
that threads 71 through all expressions applied to a form:
user> (->71 [1 2 3]
conj
conj)
[1 2 3 71 71]
user> (->71 3
+
*
-)
5183
👍 this abstraction would easily reduce our production codebase by 98.592%
@aengelberg I like your macro idea. If adopted, a corresponding thread-seventy-one-last macro->>71
would probably also be desirable, no?
I think I wouldn't mind a separate namespace with these kinds of things, though I'm not sure what it should be called.
com.gfredericks.seventy-fun
?
This is a serious project and I wouldn't want namespace names that might appear to suggest otherwise.
may i suggest com.gfredericks.⚒
This is a serious project and I wouldn't want namespace names that might appear to suggest otherwise.
com.gfredericks.seventy-fun
?
com.gfredericks.seventy-fn
?
it's still a pun
com.gfredericks.seventy-one.brevity-fns
? Serious, accurate, and rolls off the tongue.
how about com.gfredericks.seventy-one.partials
it's still a pun
com.gfredericks.seventy-pun
?
I think that's a double-negative
how about
com.gfredericks.seventy-one.semigroup.operations.associative.binary.fns
Those sure are a couple suggestions!
com.gfredericks.seventy-one.semigroup.operations.associative.binary.fns
has the additional benefit of being exactly 71 characters long, which would be useful for testing purposes
I'm way late on this, but there's always the good ol' util namespace: com.gfredericks.seventy-one.util
EDIT: I see that @aengelberg and I are on the same page! #17
Not sure if this is in scope for this library, but it seems like it might be useful. The built in multiplication operator is very flexible but allows multiplication by any number. Sometimes you just want to multiply by 71. What do you think?