This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-07
Channels
- # admin-announcements (2)
- # arachne (1)
- # bangalore-clj (2)
- # beginners (39)
- # boot (349)
- # cider (31)
- # clara (2)
- # cljs-dev (9)
- # cljsjs (67)
- # cljsrn (7)
- # clojure (300)
- # clojure-art (4)
- # clojure-greece (11)
- # clojure-hk (3)
- # clojure-israel (1)
- # clojure-italy (17)
- # clojure-japan (1)
- # clojure-russia (33)
- # clojure-sg (2)
- # clojure-spec (41)
- # clojure-uk (86)
- # clojurescript (123)
- # clojurex (3)
- # code-reviews (1)
- # component (6)
- # crypto (1)
- # cursive (36)
- # datomic (32)
- # devcards (3)
- # emacs (11)
- # events (3)
- # funcool (4)
- # luminus (10)
- # om (28)
- # onyx (88)
- # pedestal (2)
- # re-frame (84)
- # reagent (7)
- # ring-swagger (3)
- # specter (33)
- # sql (2)
- # vim (21)
The standard api is clojure.tools.logging
There are more ways to configure it, and more apis competing to replace it, than has any business being the case, alas
I’ve been using unilog lately to configure it. Declarative, simple, and easy.
Would love if someone in here has some insight into why clojure
doesn’t have always have the data last for it’s functions in the core.
For example:
(str/split <data> <regex>)
Which means I cannot partially apply the split
function like so:
(def splitByComma (partial str/split #”,”))
(splitByComma “Sentence,with,commas,all,through,it”) // noop
@cameronbourke generally Clojure functions that accept collections have the collection as the last argument, but otherwise the "data" argument is going to be the first argument (like OOP 🙂 )
(def split-by-comma #(str/split % #","))
Note: kebab-case, not headlessCamelCase, is idiomatic in Clojure.
@seancorfield Cool! Is there anywhere that goes into the rationale of doing that?
Also sorry! To used to js
haha.
Rationale of argument order? Read that blog post and see if it is what you're looking for.
@seancorfield Yeah that is actually really helpful. Espicially But what about partial?
Unfortuantely I don’t know clojure well enough to understand this work around:
> However again – as Rich's states: #() simply takes care of any problems you might have with partial[2]. #(assoc % :a 1) is even shorter than (a hypothetical) (partial assoc :a 1). [3]
As I showed above, #( ... % ... )
let's you write an anonymous function (of one argument) with that argument wherever you want.
@seancorfield That is awesome! So does %
become a placeholder? My expectation is that split-by-comma
returns a function that only accepts one param being the string in this case.
Is that right?
#( ... % ... )
is like (fn [x] ( ... x ... ))
@cameronbourke note that you can also have multiple arguments in anonymous functions by using %1, %2, etc., although beyond two args IMO it gets confusing quickly, in those cases I usually switch to regular (fn ...) syntax.
@zzamboni What is it called when calling a function in clojure using #(…)
syntax?
@cameronbourke Anonymous functions
Actually anonymous functions are (fn [...] ...)
(i.e. a function declaration without a name), #( ... )
is a reader macro shortcut version for it.
@zzamboni Aw okay, cool! But for the str/split
example above, using an anonymous function would not allow you to do #(str/split % #",”)
. Or would that look like (fn [x] (str/split [x] #”,”))
?
#(str/split % #",")
is correct, the second is almost correct: (fn [x] (str/split x #","))
@zzamboni Sweet, so there is no partial application to the function, it just wraps it with another function which accepts the placeholder value/s
if you type this in the repl (without the initial comma) you'll see that it expands to the full syntax
Cool! (fn* [p1__1258#] (clojure.string/split p1__1258# #",”))
Does anyone know any good resources for hosting Clojure web services easily (within my local network), particularly without a good understanding of either Linux or Java web servers? In my ideal world it would just be a linux VM or something along those lines that I can just throw a uberjar/uberwar at. I've got things working reasonably well on Windows with Tomcat, but I'd like to get a bit more of a Clojure standard setup for some of the future things I want to do.
@shaun-mahood: I've been enjoying using Docker. It's fast and acts similar to a VM. Use docker-compose. For Windows they have a big installer for docker and docker-compose. It's not beginner friendly and on Windows it can act oddly. But once you learn it it's extremely easy to use and powerful.
@tom: Cool, thanks.