3 ms·
> I wondered why there’s a reduce in clojure.core but no fold? (It’s just a different arity of reduce that’s missing the initial state.) There is literally an
by Jeaye 8y ago
> I wondered why there’s a reduce in clojure.core but no fold? (It’s just a different arity of reduce that’s missing the initial state.)
There is literally an arity of reduce which skips the initial state. Check out `(doc reduce)`.
> No tuple type? Vectors are tuples. “What if one of the vectors is of a different length?” I gasped as I clutched my pearl monads.
`s/tuple` is the answer to that question.
> This ties into another concept that was new to me: applying a sequence of arguments to a function.
You're not applying the sequence to the fn. This is "function application", so you're applying the fn to the sequence. In Clojure, you have some data, you apply a fn to it, then you have some transformed data. Rinse and repeat. Also, check out `(doc apply)`.
> I’ve read/heard the Clojure designers encourage the use of namespaced keywords, but I rarely encounter them outside clojure.spec definitions.
As other people have done in the comments here, I make a case for namespace keywords here [1].
> I can’t talk about data in Clojure without talking about clojure.spec!
Please be sure to check out Clojure spec's instrumentation, along with Orchestra [2] to further improve the experience. My team uses `defn-spec` for basically every fn in both our front-end and back-end code; all of the data is spec'd, with shared specs between front-end and back-end, and we get full instrumentation during development and testing. Thanks to macros, that can disappear completely in production.
1: https://blog.jeaye.com/2017/10/31/clojure-keywords/ https://blog.jeaye.com/2017/10/31/clojure-keywords/
2: https://github.com/jeaye/orchestra https://github.com/jeaye/orchestra
- lsh 8y agoOrchestra cannot be overstated. You'll quickly find the holes in clojure.spec, have a wtf? moment, feel intense disappointment then discover Orchestra and never look back.
- ataturk 8y agoI liked Clojure in 2014/2015 but like Scala and Groovy, interest has fallen way off. Seems like the JVM language wars are over. I still think everyone should learn LISP. I just don't think Clojure was that awesome. Java 8 isn't awesome, but it was good enough to kill Scala and Groovy.
- mping 8y agoCan you point that you had with spec? Isn't it a burden to define specs for everything?