This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-04
Channels
- # 100-days-of-code (8)
- # announcements (4)
- # beginners (77)
- # boot (11)
- # business (13)
- # cider (69)
- # clara (2)
- # cljdoc (51)
- # clojure (59)
- # clojure-dev (18)
- # clojure-italy (4)
- # clojure-nl (11)
- # clojure-spec (54)
- # clojure-uk (115)
- # clojurescript (33)
- # core-async (4)
- # cursive (95)
- # datomic (27)
- # duct (1)
- # emacs (58)
- # figwheel (22)
- # figwheel-main (63)
- # garden (1)
- # graphql (10)
- # hyperfiddle (1)
- # leiningen (1)
- # luminus (6)
- # off-topic (12)
- # planck (7)
- # portkey (1)
- # quil (3)
- # re-frame (3)
- # reagent (5)
- # ring-swagger (3)
- # shadow-cljs (34)
- # slack-help (19)
- # spacemacs (57)
- # testing (2)
- # timbre (2)
- # tools-deps (42)
- # yada (6)
@bones You might want to take a look at https://github.com/mikera/core.matrix either to use it or using its source as an example of how to define +
, etc operators and protocols to make them work with your custom stuff
Awesome, thanks @jesse.wertheim!
check also https://github.com/ztellman/primitive-math/blob/master/src/primitive_math.clj for method how to actually replace clojure.core/+
to custom one. Additionally there is a machinery to turn replacement on and off (https://github.com/ztellman/primitive-math/blob/master/src/primitive_math.clj#L170 and https://github.com/ztellman/primitive-math/blob/master/src/primitive_math.clj#L182)
I have generated a jar file for my clojure app, and now I want multiple entry points. So basically i want to run different functions with different commandlines. Is this possible?
@hoertlehner does this help? The clojure code
(ns app.core
(:gen-class))
(defn -main
[& args]
(case (first args)
"a1" (println "hello")
"a2" (println "hi")))
then create the uberjar
then try:
java -jar app.jar a1
>>> hello
java -jar app.jar a2
>>> hi
@hoertlehner for more complicated scenarios https://github.com/clojure/tools.cli
Hello guys, could anyone explain me differences and implications between :keyword
and ::keyword
?
::keyword
will expand to :<namespace>/keyword
for the current namespace
to expand a bit, ::foo
is just a reader macro to expand into :<current_namespace>/keyword
, a keyword in the form of :foo
is called a non-namespaced (or simple) keyword, a keyword in the form of :foo/bar
is a namespaced keyword
there's been a shift in the recent years (mostly thanks to spec) to using namespaced keywords when possible, in order to convey better semantic meaning (e.g. what does :name
mean? but :person/name
vs :country/name
make it clear), while still using unnamespaced keywords mostly for syntax (e.g. in macros like (for [x xs :when x] ..)
)
so let's say I want to code a library. current best practice guides me to use namespaces keywords, so it is clear that this thing belongs to me and has this exact meaning when used with my library? Which I can perceive as prefixed keywords, right? Is there any effect in term of memory management for example or is it just in the boundaries of semantics?
yep, that's exactly it - if you have a library it is usually best to namespace your keywords, to be precise in the meaning and to avoid clashing with end user keywords
I don't know about the implications for memory management
How do you start Clojure 1.10 (alpha) REPL, please? Do you invoke it as: java -jar ~/Downloads/clojure-1.10.0-alpha5.jar
or in what way?
I have Sun JDK 10.0 and OpenJDK 11 on a RPM-based Linux (SUSE). I tried both JDKs with clojure-1.10.0-alpha8.jar
and two more jars from https://repo1.maven.org/maven2/org/clojure/clojure (and one from http://maven.org). All fail with:
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.base/java.lang.Class.forName0(Native Method)
....
Caused by: java.io.FileNotFoundException: Could not locate clojure/spec/alpha__init.class or clojure/spec/alpha.clj on classpath.
at clojure.lang.RT.load(RT.java:463)
....
I also tried to build it from source, failed again.
@peter.kehl no, use the clj
tool
@ales.najmann yeah that's correct, no performance hit really
hey guys. i've just tried to build a new clojurescript project with reagent using lein new figwheel my-app -- --reagent
. however on starting with lein figwheel
i get a bunch of errors in the console complaining about being unable to find react, e.g.
Uncaught Error: goog.require could not find: create_react_class
at Object.goog.require [as require_figwheel_backup_] (base.js:681)
at component.cljs?rel=1538661740772:1
anyone got any ideas?I vaguely remember something about create-react-class being deprecated in newer versions of React
@bronsa @danieleneal thank you for your time explaining this to me ❤️
@bronsa Where do you get clj
tool for 1.10 aplha?
that is, clj
is agnostic to the Clojure version you want to use, so there is no such thing as “clj tool for 1.10 alpha”, there is just “clj”, which can be used with 1.10 alphas: clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version "1.10.0-alpha8"}}}'
@helenelizabethwilliam did you alter the generated project?
(but you can specify any other version of Clojure there too)
@helenelizabethwilliam I just launched it and didn’t get these errors
this was in another clojurescript project, creating using the command i was running lein figwheel
. lein figwheel stopped working so i tried creating a brand new project, which also didn't work
Thanks @bronsa and @alexmiller.
@peter.kehl How were you running REPLs for Clojure 1.9 etc? You can use the exact same tools -- just specify a different version of Clojure as a dependency. That works for lein
, boot
, and clj
.
I was working on a solution for: http://www.4clojure.com/problem/19#prob-title i know people used
(first (reverse coll))
but i wonder if my solution for not using reverse is acceptable
(fn my-rest [a-seq]
(cond
(empty? (rest a-seq)) (first a-seq)
:else (recur (rest a-seq))))
I think that logically it works! You could use if
instead, and avoid calling rest twice with destructuring.
(fn my-rest [[fseq & rseq]]
(if (empty? rseq)
fseq
(recur rseq)))
and because of how destructuring handles empty rest-destructure, (if-not rseq ...)
would also work
(or (if rseq ...)
and flip the two clauses)
right
oh, sweet, thanks!
the nil-pun of empty collection that seq
does can really make things more concise
destructuring seems really nice, saves me from having to use local bindings (let)
i tend to solve some problems using structural recursion on sequences, because seems a lot easier for me, and then i try to simplify the code
I want to study spec lib, any good resources aside clojure website ?
@UD4SQ29M1 as well as the great spec guide on http://clojure.org, https://pragprog.com/book/shcloj3/programming-clojure-third-edition has a good chapter on it
Are you looking for something like Insomnia? https://insomnia.rest/
hey guys, one quick question. I’m doing my api and something bother me. My handler is calling something like a service “layer” of functions should I validate the params in the handler or into my service ? I mean, should verify the spec on the handler or inside my service layer ( my handlers are super thin , just orchestrating the flow )
one approach I have seen recommended is to put the validation at the system boundary, and I'd argue that the system boundary here is where the client communicates with server, so validate the request rather than the function calls
thanks @noisesmith
Hi, I do a query in datomic with pull syntax and I get this:
[#:user{:id #uuid "ef23d1a1-ac61-4a8a-9448-61d14c1ec13d", :first-name "Sozuke", :last-name "aizen", :email "
A simple question: What does #:user
signify here?
it's a namespaced map syntax
user=> {:user/foo 1 :user/bar 2}
#:user{:foo 1, :bar 2}
right
you can also make map literals that way
user=> (= {::foo 1 ::bar 2} #:user{:foo 1 :bar 2} {:user/foo 1 :user/bar 2})
true