Fork me on GitHub
#clojure-nl
<
2021-01-17
>
borkdude15:01:03

Are you familiar with core.match? After the core.logic workshop on Wednesday, this looks oddly familiar:

$ ./bb -e "(require '[clojure.core.match :as m]) (m/match (range 100) ([_ _ _ _ & r] :seq) (first r))"
4

borkdude15:01:33

$ ./bb -e "(require '[clojure.core.match :as m]) (m/match [0 1 2 3] [0 a 2 b] [a b])"
[1 3]

Stefan15:01:28

Well, I know it exists, but not much more than that :) Isn’t that the lib that also allows you to do more advanced pattern matching on fn arts, a la Haskell?

borkdude15:01:59

it's basically a more sophisticated case but I don't think you can use it for defining functions

borkdude15:01:39

but you can use it like this:

(defn foo [& args]
  (m/match args
    [0 1 a] a))

borkdude15:01:37

Actually, like this:

(defn foo [& args]
  (m/match args
           ([0 1 a] :seq) a))

Stefan15:01:04

Yes, very nice I think. Have you used it “in anger”?

borkdude15:01:03

No, I haven't. Just started experimenting with adding it to babashka (because it was requested here https://www.reddit.com/r/Clojure/comments/kyke06/please_vote_if_youre_interested_in_seeing/)

borkdude15:01:08

Hmm, that site makes your fans spin though

Mno16:01:12

oh boi, I always immediately assume crypto mining when my fans start spinning on a website

borkdude16:01:59

That problem has now been fixed btw

borkdude16:01:03

Quick reaction by the maintainer

Mno16:01:25

Impressively quick