Morning
Morning
morning!
Babashka survey: https://nl.surveymonkey.com/r/H2HK3RC
Good morning! I'm trying to understand why
(reduce str "1") => \1
Morning
That's weird. But (reduce str "" "1")
does work.
Btw, (apply str ...)
might be better so there's only one StringBuilder
is it going to assume that the string is a seq of characters?
I think you’re seeing a couple of things. If I remember correctly, reduce will not invoke the reducing fn if there is only one element in the list
And, as discussed previously, a string is considered a sea of chars, as @otfrom points lit
There is a mailing list entry (or something) somewhere where Rich regrets the two arity version of reduce for several reasons.
Could make a clj-kondo rule for this: always provide an identity element
If you could point me to the Rich entry on this, could post it in an issue
thanks!
Thanks. I didn't run into trouble with this. I was just trying to understand reduce a bit better and one of my experiments gave me that funny result.
Hint: the other name for String is CharSequence ;) and reduce with this arity assumes that an element combined to no other reduces to itself.
anyone here had a play with flow-storm-debugger? https://github.com/jpmonettas/flow-storm-debugger