Fork me on GitHub
#clojure
<
2018-04-08
>
qqq05:04:32

What is a good name for the foo function below?

(defn foo [f ks]
  (into {} (for [k ks] [k (f k)])))

(foo #(* % %) (range 3))
(comment
 {0 0, 1 1, 2 4})

the2bears05:04:54

@qqq 'mapf' maybe? 'map-keys'? Neither seems quite right...

qqq05:04:03

the best name I have so far is (k->v)->ks->map<k,v> but that is not a valid clojure symbol name

qqq05:04:58

clearly, the solution is to use unicode chars 🙂

the2bears05:04:56

Not a fan of that, but if you are consider 'mapk->fk'?

qqq05:04:10

I think text obfuscated the sarcasm in suggesting (k->v)->ks->map<k,v> -- I'd really prefer english words to type sigs 🙂

👍 1
andy.fingerhut06:04:39

partial-fn->map ?

1
💯 1
andy.fingerhut06:04:15

It is a map that represents a partial version of a function.

leongrapenthin12:04:50

I'd call it memo-map.

alex-dixon15:04:37

Anyone have a minimal prepl example?

dominicm08:04:11

It depends.

dominicm08:04:50

There's no single answer, and the divide of which to choose is rather large.

😄 1