Fork me on GitHub
#clojure-europe
<
2021-04-20
>
dharrigan06:04:41

Good Morning!

pez06:04:52

Good morning!

thomas08:04:41

an ex-colleague has asked for a book recommendation regarding an intro into FP. Any suggestions? Not Clojure specific though, I have suggest Eric Normand's book as a started (even though I haven't read it myself).

ordnungswidrig08:04:33

I ikead “Real World Haskell” if you want to go hard core.

thomas08:04:24

I suspect these people won't use Haskell as this is Enterprise:tm: stuff... 😉

javahippie08:04:57

Is SICP too hard? If they are already developers, it should hit some interesting topics, shouldn’t it?

ordnungswidrig09:04:09

@thomas still it’s a very good introduction into FP I think. SICP of course, too!

borkdude09:04:33

If the goal is to do Clojure eventually, I personally wouldn't bother with Haskell since it comes with a lot of baggage that isn't very relevant in Clojure. Conceptually separating side effects from pure functions is very useful, but you will learn those concepts with Clojure as well.

thomas09:04:29

I think the goal is more FP in general, not Clojure or Haskell.

javahippie09:04:34

We are all obviously biased here, but I think that Lisp is really a great teaching language for FP. I agree with the introduction of Software Design for Flexibility, you can concentrate on the context without being “distracted” by a static type system.

ordnungswidrig09:04:47

Different topic: does somebody know a good library for longest/critical path analysis in clojure? (Or java if that helps)

borkdude09:04:43

what is longest/critical path?

ordnungswidrig10:04:37

if you have a DAG of nodes, each with a weight. The longest path is the path along the nodes which give the heighest sum.

ordnungswidrig10:04:16

critical path is the path where increasing the node weight increases the weight sum of the longest path.

djm10:04:54

I haven't read them, but O'Reilly has some "generic" functional programming books - Becoming Functional and Functional Thinking. They might be worth looking at (I think they're both jvm-centric; the latter includes at least some Clojure)

refset10:04:12

I don't know much about Loom (i.e. not enough to recommend it), but this API looks about right https://cljdoc.org/d/aysylu/loom/1.0.2/api/loom.alg-generic#dijkstra-path

borkdude10:04:30

We use a Java lib for these kinds of things, it's called jgrapht and very performant

dominicm19:04:30

Funnily enough, I tried rewriting an alg moving from loom to jgrapht for performance and it was much worse under jgrapht. I think loom had a particularly good algorithm for doing connected graphs that jgrapht didn't.

ordnungswidrig10:04:13

I wonder if my DAG size of 60k nodes is off the charts.

otfrom10:04:24

that is a fair number of steps

ordnungswidrig10:04:00

I wonder if the calculating the shortest path is even helpful / sufficient to get the critical path

javahippie10:04:06

If I remember correctly, both loom and ubergraph have builtin functions for shortest path

javahippie10:04:11

Ah, did not see that @U899JBRPF already posted that, sorry!

😄 4
ordnungswidrig10:04:23

they do. will explore and report. See you in a couple of week 😛

👋 12
ordnungswidrig12:04:01

Uhhm, [[:a 1] [:b 2] [:c 3]] => [[:a :b :c] [1 2 3]] … how?

ordnungswidrig12:04:31

[(map first xxx) (map second xxx)] doesnt sound too tempting

borkdude12:04:56

The rule of juxt: always use it when possible (juxt #(mapv first %) #(mapv second %))

ordnungswidrig12:04:09

but this would be double-iterating

ordnungswidrig12:04:18

maybe doesn’t matter.

plexus12:04:28

If you're using juxt there then you really should also use partial

borkdude12:04:52

you can single-iterate with a reduce but this would be more boilerplate. if you go that way, then you absolutely must use transients as well

borkdude12:04:02

and plexus is right

plexus12:04:05

(map apply vector c1 c2)

ordnungswidrig12:04:25

that’s the wrong way round

borkdude12:04:32

oh yes matrix transposition, apply map vector

plexus12:04:45

Ah but is it?

plexus12:04:58

Yeah I think so

borkdude12:04:45

$ bb -e '(apply mapv vector [[:a 1] [:b 2] [:c 3]])'
[[:a :b :c] [1 2 3]]

plexus12:04:27

Ah yes I did have it the wrong way round :)