gfredericks / seventy-one

71 in Clojure
Eclipse Public License 1.0
39 stars 9 forks source link

Implementation of multiplication by 71? #16

Open seako opened 7 years ago

seako commented 7 years ago

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?

gfredericks commented 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.

aengelberg commented 7 years ago

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
aengelberg commented 7 years ago

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
dennyabraham commented 7 years ago

👍 this abstraction would easily reduce our production codebase by 98.592%

seako commented 7 years ago

@aengelberg I like your macro idea. If adopted, a corresponding thread-seventy-one-last macro->>71 would probably also be desirable, no?

gfredericks commented 7 years ago

I think I wouldn't mind a separate namespace with these kinds of things, though I'm not sure what it should be called.

aengelberg commented 7 years ago

com.gfredericks.seventy-fun?

gfredericks commented 7 years ago

This is a serious project and I wouldn't want namespace names that might appear to suggest otherwise.

dennyabraham commented 7 years ago

may i suggest com.gfredericks.⚒

Hendekagon commented 5 years ago

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?

gfredericks commented 5 years ago

it's still a pun

aengelberg commented 5 years ago

com.gfredericks.seventy-one.brevity-fns? Serious, accurate, and rolls off the tongue.

gfredericks commented 5 years ago

how about com.gfredericks.seventy-one.partials

Hendekagon commented 5 years ago

it's still a pun

com.gfredericks.seventy-pun?

I think that's a double-negative

Hendekagon commented 5 years ago

how about

com.gfredericks.seventy-one.semigroup.operations.associative.binary.fns

gfredericks commented 5 years ago

Those sure are a couple suggestions!

Hendekagon commented 5 years ago

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

daveyarwood commented 5 years ago

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