Fork me on GitHub
#clojure-europe
<
2022-04-20
>
pez06:04:21

☀️

otfrom07:04:02

I like cheatsheets and nutshell books b/c it reminds me of things I've forgotten or shows me things I'd not noticed the first time: https://clojure.org/api/cheatsheet

🧠 1
genRaiy09:04:01

I took a quick look and discovered memfn which has been there since the primordial soup of 1.0. Who knew?

simongray11:04:12

@raymcdermott TIL! Seems very useful, but I’ve probably forgotten about it by the time I need to write Java interop code 😛

😂 1
otfrom07:04:11

dedupe being today's example

otfrom07:04:42

but good to know it is distinct from distinct

😂 5
simongray11:04:44

in cases where duplicates are always consecutive it is performant, but how often do you only need that??? kind regards, someone who once introduced a bug because of dedupe

simongray11:04:07

I guess if you want to produce random results it can make sense to use dedupe to clean the output up…

genRaiy08:04:25

Good morning

maleghast08:04:34

Madainn mhath

nottmey08:04:57

Good morning! 🙂

simongray09:04:27

good morning

simongray09:04:47

I hope everyone has had a nice Easter holiday

simongray09:04:16

I didn’t write any code for a whole week!

🙀 1
genRaiy10:04:04

not really related to @otfrom’s good advice but just stumbled over requiring-resolve which was added in 1.10

genRaiy10:04:22

I changed some ugly code from this

(ns-resolve (do (require 'some-ns)
				(the-ns 'some-ns)) 'some-var)

genRaiy10:04:42

(requiring-resolve (symbol (str var-ns "/" var)))

genRaiy10:04:22

[ for resolving functions from data definitions ]

genRaiy10:04:40

Is there a better way?

simongray11:04:49

@raymcdermott There is also a 2-arity version of symbol , i.e. (symbol var-ns var) , although for some stupid reason it requires both args to be strings whereas the other version does not.

1
pez11:04:57

Sure the reason is stupid? 😃

simongray11:04:03

I looked at the source code

metal 1
genRaiy12:04:33

so it's (str var-ns) (str var) vs (str var-ns "/" var) . Maybe the former is slightly more elegant.