mornin’
Good Morning!
Good morning!
morning
mawning
morning
morning
morning
Bonjour!
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).
I ikead “Real World Haskell” if you want to go hard core.
I suspect these people won't use Haskell as this is Enterprise:tm: stuff... 😉
Is SICP too hard? If they are already developers, it should hit some interesting topics, shouldn’t it?
@thomas still it’s a very good introduction into FP I think. SICP of course, too!
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.
true that.
I think the goal is more FP in general, not Clojure or Haskell.
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.
Different topic: does somebody know a good library for longest/critical path analysis in clojure? (Or java if that helps)
what is longest/critical path?
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.
critical path is the path where increasing the node weight increases the weight sum of the longest path.
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)
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
Nice.
We use a Java lib for these kinds of things, it's called jgrapht and very performant
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.
I wonder if my DAG size of 60k nodes is off the charts.
that is a fair number of steps
I wonder if the calculating the shortest path is even helpful / sufficient to get the critical path
If I remember correctly, both loom and ubergraph have builtin functions for shortest path
they do. will explore and report. See you in a couple of week 😛
Ah, did not see that @taylor.jeremydavid already posted that, sorry!
Uhhm, [[:a 1] [:b 2] [:c 3]]
=> [[:a :b :c] [1 2 3]]
… how?
[(map first xxx) (map second xxx)]
doesnt sound too tempting
The rule of juxt
: always use it when possible
(juxt #(mapv first %) #(mapv second %))
but this would be double-iterating
maybe doesn’t matter.
If you're using juxt there then you really should also use partial
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
and plexus is right
(map apply vector c1 c2)
that’s the wrong way round
oh yes matrix transposition, apply map vector
Ah but is it?
Yeah I think so
$ bb -e '(apply mapv vector [[:a 1] [:b 2] [:c 3]])'
[[:a :b :c] [1 2 3]]
aaahm
oh
Ah yes I did have it the wrong way round :)