This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-01
Channels
- # beginners (10)
- # cljs-dev (33)
- # cljsjs (4)
- # cljsrn (12)
- # clojure (39)
- # clojure-belgium (2)
- # clojure-russia (80)
- # clojure-spec (9)
- # clojure-uk (6)
- # clojurescript (22)
- # core-async (141)
- # cursive (2)
- # datomic (20)
- # devops (1)
- # emacs (20)
- # hoplon (1)
- # jobs (3)
- # lambdaisland (12)
- # leiningen (3)
- # lumo (44)
- # onyx (2)
- # pedestal (1)
- # quil (1)
- # re-frame (9)
- # reagent (4)
- # robots (1)
- # rum (3)
- # spacemacs (5)
- # uncomplicate (80)
- # untangled (46)
- # yada (2)
It's ok to validate things outside of spec too
@hmaurer Clojure 1.9 is stable enough for production use as far as I’m concerned — my company has Clojure 1.9 Alpha 17 in heavy production usage right now.
does anyone have recommendations on a good job scheduling library for Clojure? checked out Quartzite earlier, but had some difficulty getting it to play nicely with my loading of env vars from mount
Should I follow kibit's recommendations?
Consider using:
(vec costs)
instead of:
(into [] costs)
Is there any real difference between vec
and into []
?
vec
is a bit shorter and maybe more explicit but I've also seen into []
being used a lot.
I've found following question on SO: https://stackoverflow.com/questions/12044181/into-or-vec-converting-sequence-back-to-vector-in-clojure but I don't think the different behavior for small arrays mentioned in answer is trueI did following experiment:
(def my-a (int-array [1 2 3]))
(def my-v (vec my-a))
my-v
;=> [1 2 3]
(aset my-a 1 10))
(java.util.Arrays/toString my-a)
;=> "[1, 10, 3]"
;=> my-v
[1 2 3]
@jumar it can't alias an int-array
+user=> (def a (into-array [1 2 3]))
#'user/a
+user=> (def v (vec a))
#'user/v
+user=> a
#object["[Ljava.lang.Long;" 0x5c089b2f "[Ljava.lang.Long;@5c089b2f"]
+user=> (seq a)
(1 2 3)
+user=> v
[1 2 3]
+user=> (aset a 1 42)
42
+user=> v
[1 42 3]
as you see, it can alias a Long array
if the collection might in some cases already be a vector, or it's an array that won't be aliased, use vec
if you already have a vector and need to add to it, or if you need to do some transformation like mapping or filtering as you add things, use into
if none of those conditions apply, it doesn't matter which you use
when I mention transforms here, I'm talking about using the transducing arg to into btw
Hello,I am new here and to Clojure too,Is it okay if I post some code here to resolve an issue?
yes @diginomad, you can ask it here -- there is also a #beginners channel that you may find helpful if your issue is not resolved here
Hi @joshjones, thank you for the response
and tried to implement https://www.youtube.com/watch?v=f6kdp27TYZs&t=1600
i would recommend you ask in #core-async -- providing some details as to how specifically you are stuck
How to make class self as type hint for field of deftype
?
(deftype Foo [^some.ns.Foo parent])
Has anyone see this error when trying to start your repl: Exception in thread "main" java.net.SocketException: Protocol family unavailable, compiling:
?
is this something that happens in every project, or only when loading a specific project's code?
sometimes I find that if I don't use lein's init-ns
or main
features, and just call require from user, the error is more informative
for example
$ lein run -m clojure.main
user=> (require 'my.ns)
then I get a better idea of what code is blowing up
Does anyone know how to create a parameterized type instance (java interop)? E.g. new MyPType<Integer>
@kingcode that doesn't actually exist
it's a thing the java compiler pretends is there, but isn't actually a thing in the relevant bytecode
@noisesmith mith ok thx!
@kingcode right, type erasure (with the exception that you can use reflection to find the generic type - but that's not actually as relevant as one might think)
the important thing is the code just works without it