I've been wondering why core has all these fns like interleave
, interpose
and other neat sequence functions. To me they seemed, well, neat, but nothing I ever reach for in my day to day work. But then I tried to write a macro, and they made a lot more sense.
Oh, and good morning!
Morgen
Morning
Morning
Dia Duit!
I used interpose a lot in the past, it's great to generate token (comma, AND, OR etc) separated strings and since it has a transducer arity you can compose with it nicely and "realize" the final thing with a single call to transduce + a string-builder reducing fn
(ex context clojure dsl -> some string based query language)
You can do the same with str/join but you loose the ability to do it in a single pass when you need to also work on the values passed to it, think (str/join "," (map tranform xs)) vs (transduce xform string-builder xs), where string-builder and xform can be heavily optimized for what you need to generate
Morning
I needed interleave
to process namespace forms and interleave the namespace names with :reload
, so you get:
(ns foo (:require [foo :as f] bar)
=>
(ns foo (:require foo :reload bar :reload)
Good morning!
good morning!
š @web20
morning!
morning
Another one of those things that feel ok to discuss in here.
user> (= 1 1 1)
;; => true
user> (= 1 1)
;; => true
user> (= 1)
;; => true
user> (=)
Execution error (ArityException) at user/eval73949683 (form-init4579255747461836344.clj:2764).
Wrong number of args (0) passed to: clojure.core/=
this blows up when you do (apply = xs)
and xs
is empty
(= nil)
=> true
true yes, I've had that exception as well
maybe this is like (-)
because =
doesn't have an identity element?
Could be, but it also seems like <
and >
behaves this way.
I guess this is somewhat violating the principle of least surprise.
I think I'd be happy if =
was two-arity, I'm pleasantly surprised by it being multi-arity, but then again, a bit annoyed that it's not zero-arity.
I'm sure there's a reason it doesn't return true or false by default
one thing is equal to itself. but zero things...?
undefined I would say
Am I equal?
morning
lol
user> (< 3)
;; => true
user>
Don't know if that makes sense?
(> 3)
true
hmm, 3 is both smaller and greater than... somethinguser> (= 3)
;; => true
user>
user> (not= 3)
;; => false
user>
(and) the universal truth
This is so disturbing I might have to move on to Haskell or Idris or somehting.
@slipset We can make a clj-kondo rule that says: don't use varargs comparison: always use reduce
+ an explicit identity ;)
I guess this is the kind of runtime errors I have a hard time accepting, And why I now always use the three-arity reduce
I can handle (runtime) type-errors as they don't crop up too often, but runtime-lack-of-nil-punning sucks.
Same difference when using clojure.string
I guess
lack of zero-arity isn't the same as nil-punning though
I would say an error is better than silently returning true of false here
(when (seq things) (apply = things))
, it's a bit annoying
And Zach thinks (get nil :foo)
should be error as well.
What about (:foo nil)
You could argue that map lookups should always be done with a sentinel-value
(:foo nil :not-found)
or: (or (:foo nil) (throw (ex-info "up" {}))))))))
(I didn't know how many closing parens I should type, so I just ensured there were enough)
I guess what Zach argues is that when you to a map-lookup on nil
you change the type of nil
, if that makes sense.
(:foo nil :not-found)
is supported in Clojure BTW
ok let me know how it goes in Haskell land and see you back in a year or two :)
rofl
< and > aren't less-than or greater-than, they are increasing and decreasing (or at least that is the only way I can remember
I just saw an AWS update that Corretto JDK 11 now supports Shenandoah GC, and it turns out it was backported to JDK11. I wonder if someone has used it with Clojure programs and has any experience report?
I'd certainly be up for any GC/jvm tuning tips
I suppose there is this: http://clojure-goes-fast.com/blog/shenandoah-in-production/
@otfrom Yeah, the docstring says so. That would explain the behavior or (< 3)
<3
still waiting for someone to release a fork of clojure.string that nil-puns
Totally unrelated, http://mailbox.org looks great
Yep, I moved to that and I'm pretty happy with that so far
How accurate is the spam filtering? I suffer from an increasing amount of spam mails in my inbox and now Iām thinking about rolling my own mail setup (again) :white_frowning_face: