This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aws (4)
- # aws-lambda (2)
- # beginners (67)
- # boot (38)
- # cider (32)
- # cljs-dev (12)
- # cljsrn (2)
- # clojars (2)
- # clojure (190)
- # clojure-chicago (1)
- # clojure-dusseldorf (2)
- # clojure-germany (1)
- # clojure-greece (3)
- # clojure-italy (5)
- # clojure-russia (6)
- # clojure-spec (47)
- # clojure-uk (10)
- # clojurescript (59)
- # cursive (9)
- # data-science (14)
- # datomic (24)
- # devops (16)
- # emacs (8)
- # fulcro (25)
- # graphql (30)
- # hoplon (123)
- # juxt (15)
- # lambdaisland (2)
- # leiningen (4)
- # luminus (6)
- # lumo (9)
- # off-topic (11)
- # om (7)
- # onyx (8)
- # re-frame (14)
- # reagent (5)
- # ring-swagger (5)
- # shadow-cljs (46)
- # spacemacs (41)
- # specter (8)
- # testing (8)
- # unrepl (31)
- # yada (18)
Anyone have any good libraries for improving the output presentation of stacktraces?
You might also be interested in https://github.com/pjstadig/humane-test-output (although it's not for stacktraces).
Hi! I have this code
(apply partial f args), where
args are a user supplied function and arguments. When the resulting function is called it appends any arguments to the end. How can I make it so that the resulting function uses a single supplied argument as the first argument to
I'm following the official guide from http://clojure.org and have unexpected result from this exercise:
Here is my attempt:
Define a function triplicate which takes another function and calls it three times, without any arguments.
And the result of calling
(defn triplicate [callee] ( (callee) (callee) (callee))) (triplicate #(println "Hello"))
So it seems like the program does what is expected (prints
Hello Hello Hello Exception in thread "main" java.lang.NullPointerException, compiling:(/home/tadeusz/Projects/clojure-playground/functions.clj:8:1) at clojure.lang.Compiler.load(Compiler.java:7391) at clojure.lang.Compiler.loadFile(Compiler.java:7317) at clojure.main$load_script.invokeStatic(main.clj:275) at clojure.main$script_opt.invokeStatic(main.clj:335) at clojure.main$script_opt.invoke(main.clj:330) at clojure.main$main.invokeStatic(main.clj:421) at clojure.main$main.doInvoke(main.clj:384) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.lang.Var.invoke(Var.java:379) at clojure.lang.AFn.applyToHelper(AFn.java:154) at clojure.lang.Var.applyTo(Var.java:700) at clojure.main.main(main.java:37) Caused by: java.lang.NullPointerException at user$triplicate.invokeStatic(functions.clj:3) at user$triplicate.invoke(functions.clj:1) at user$eval2.invokeStatic(functions.clj:8) at user$eval2.invoke(functions.clj:8) at clojure.lang.Compiler.eval(Compiler.java:6927) at clojure.lang.Compiler.load(Compiler.java:7379) ... 11 more
Hellothree times, but then the exception is thrown. Why? The same happens if I paste it into REPL.
@tadeusz since the function calls are wrapped in parens, it is also interpreted as a function call
nil is in the first position, it is interpreted as a function call, and that is why you get NullPointerException
to solve it, either remove the parens around it, or put a
do in front:
(do (callee) (callee) (callee))
for example if you have a let block
is invalid syntax
(let [foo (callee) (callee) (callee)])
I can see how this wrap in parens to execute can be used to write very concise programs.
@tadeusz functions basically put the
do around their body for you, which is why you don't need it inside them
Hey guys, it seems function returns DateTime object instead of timestamp and test fails because of that… Any ideas?
your function is returning a joda time while you are expecting the
(java.util.Date.) type. Is the expectation in error or the function return type in error?
this is similar to expecting a long
3 and getting a decimal
3.0. They are similar but you need to compare them with respect to their differences, if that makes sense. Although it should be noted that the timestamps in your tests aren't the same time
ah, if you require
clj-time it will change your timestamps to joda. not sure if that's what's going on here.
so you'll need to unify those types to compare them. either joda -> jata util date or the reverse
check out how to use clj-time. rather than
timestamp (java.util.Date.) just make a joda timestamp from the get-go
excellent! the printer was telling you the reason they were different
:timestamp #object[org.joda.time.DateTime versus
#inst. Different types have different ways of printing
Hey guys could someone help me with this?
I have an jar file that i have build with
lein uberjar that uses a log4j2.xml to set up the application logging.
The xml file is in the resources folder but when I run
java -jar -Dlog4j.configurationFile=/resources/log4j2.xml ./target/app-standalone.jar. I keep getting a
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
lein run works fine
is there an option like configurationResource - I don’t know log4j but maybe they care about “File”
quick google makes me think maybe
-Dlog4j.configuration=... which takes a URL but maybe without a protocol it would accept a resource path?
@joelv also if you eliminate the arg altogether it will use the first log4j2.properties it finds anywhere on classpath (which would include inside your jar)
have you contributed to any? @donaldball like do you know which ones are good for beginners and intermediates?
Variously, as I’ve had itches that needed scratching, but not working from that registry. There are projects specifically tagged as beginner friendly there.
I just want to say a big thank you to everyone that helped me over the past couple of weeks to understand stuff around sequences and some of the core functions like map, etc. You guys rock!
@yogidevbear this is by far the best community I’ve ever seen. I always get awesome advices and answers to my newbie questions.