Fork me on GitHub
#off-topic
<
2022-02-17
>
vlaaad19:02:07

What's the shortest way to spell identity ?

vlaaad19:02:41

First I thought of #(-> %) , and then of (comp) ... is there anything shorter?

lsenjov19:02:25

I didn't realise (comp 1) worked. That's either neat or terrifying

phronmophobic19:02:23

same with conj

phronmophobic19:02:09

even shorter is min or max

hiredman19:02:47

same character count #({}% %)

hiredman19:02:29

oh, no, one more 馃槙

phronmophobic19:02:45

if macros are allowed, then I think or is the shortest

phronmophobic19:02:08

otherwise, I think the shortest is 3 characters using min or max

adi19:02:00

Well, I suppose (def i identity) and then (i ...whatever...) would amortize very fast (if we discount the keystrokes expended in this discussion 馃榿 ).

Michael Gardner19:02:27

it's silly to complain about, but I do wish identity, partial and complement had shorter names

flowthing20:02:20

user=> (require '[clojure.core :refer [identity comp partial] :rename {identity id comp 路 partial $}])
nil
user=> (map id [1 2 3 4])
(1 2 3 4)
user=> ((路 ($ apply str) reverse str) "Hello, world!")
"!dlrow ,olleH"
Just to expand on what Alex said. 馃檪

flowthing20:02:43

Whoops, complement, not comp... well, anyway.

Martynas Maciulevi膷ius20:02:49

So... would one consider this as code duplication if the names are long? 馃槃

Michael Gardner22:02:23

I'm aware you can do that, but you'd have to do it everywhere (or use hacks like Leiningen injections). Not worth the effort, which is why defaults are important

Alex Miller (Clojure team)19:02:50

you can give them any shorter name you like :)

manutter5120:02:33

Just don鈥檛 ask ME to maintain your code if you do 馃槈

p-himik20:02:15

That reminded me of keyboard layouts like this one.

Alex Miller (Clojure team)20:02:02

seriously though, given their frequency of use, I think it's ok that these are longer

1
slipset07:02:44

chicken, egg? Would they have seen more use if they were shorter?

Stuart21:02:26

If you just want to have them not display as long, you can setup your editor to show whatever text you want as a substitution. e.g.

lightsaber 2
Stuart21:02:22

I like just changing this stuff at the editor display level as it means that if you are working on shared code you can just write regular code for the language, then each person can decide how its displayed.

Stuart21:02:49

That and shortcuts / snippets seems a good solution to me

Stuart21:02:26

i.e. i have ALT+C setup to enter (comp _) where _ is where the cursor lands.