This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-25
Channels
- # architecture (4)
- # bangalore-clj (3)
- # beginners (11)
- # chestnut (1)
- # cider (24)
- # cljs-dev (14)
- # clojure (97)
- # clojure-finland (1)
- # clojure-gamedev (19)
- # clojure-italy (11)
- # clojure-nl (31)
- # clojure-norway (1)
- # clojure-uk (52)
- # clojurescript (71)
- # core-async (4)
- # cursive (60)
- # datascript (8)
- # datomic (115)
- # emacs (29)
- # figwheel (11)
- # fulcro (3)
- # garden (1)
- # hoplon (1)
- # lein-figwheel (1)
- # leiningen (7)
- # luminus (13)
- # mount (1)
- # off-topic (51)
- # onyx (31)
- # pedestal (2)
- # portkey (1)
- # re-frame (22)
- # reagent (22)
- # reitit (6)
- # remote-jobs (1)
- # schema (1)
- # shadow-cljs (73)
- # specter (2)
- # sql (1)
- # unrepl (3)
- # vim (11)
- # yada (4)
@seancorfield :for some reason, I was trying (.count ...) instead of (count ...)
Overthinking/over-complicating things? 🙂
One of the things that still charms me, almost daily, working with Clojure, is that so often the very simplest thing I can imagine is what works!
I have done Clojure + Cuda via ClojureCuda. I have done Clojure + OpenGL via JOGL. However, I don't know how to mix the two. Does anyone have sample Clojure glue where the Cuda code writes to a VBO, which the JOGL code then picks up for rendering? I suspect this is possible, but just have not done this yet.
Is there a pretty-print version of pr-str
? I have a data map which I need to pr-str
, but would like to keep that pretty formatted.
@sundarj the thing is that some of keys in the map are Records, so when I do with-out-str
with pprint
I lose the tags for those records, so later on I cannot read them back.
i see. at a guess, you would have to muck about with pprint's configuration to change that
You can extend the print multimethods to support record instances
If I have a legacy java jar, not on maven or whatever, and I want to use it in my clojure project (leiningen for building), what is the best way to use it?
i read somewhere it should be in the lib/ dir in my project, is that all that’s needed?
@kah0ona I generally just upload the jar to my local maven repo and then treat it like any other jar: https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project
Is there any practical (performance maybe?) difference between:
(->> data (mapcat transform-fn) (into []) ;; which will expand to (into [] (mapcat transform-fn data))
and
(into [] (mapcat transform-fn) data)
or is this just a visual preference thing
(insert obvious missing )
after (into [])
)
@tankthinks the second one is faster as it does not materialize the intermediate collections (https://clojure.org/reference/transducers is a good read)
that’s what I thought … yup … should have checked the docs 😃
Hi! Have a question about reader conditionals: I want something like :nodejs
to separate browser and nodejs environment. However, I can't find a way how to extend reader conditionals features set. I've tried to use something like (= :nodejs (get-in @cljs.env/*compiler* [:options :target]))
, but it is doesn't work in cases like :require
in ns
macro, for example. Is it possible to extend this feature set? any links on how to do that? thanks!
reader conditional features are not currently extensible
The original design was extensible and in fact the reader implementations actually do support extensible features. However, in the end we decided to reduce scope and make the “platform” features hard-coded for the purposes of reading source code. (You can activate custom features through the reader api when you are controlling the read.)
The problem with custom features is that you are then potentially inviting an explosion of code “variants” and we would like to exert as much negative pressure on that as possible.
We may revisit this in the future but no plans to change it in the short term.
Suppose I have a vector like (def myl [[[1]] [[2] [3]]])
Is there a way to partially flatten it and get [[1] [2] [3]]
?
flatten does actually too much
ah dammit apply concat
might work
@andrea.crotti see also mapcat
one of my favorite things is the transducer variant of mapcat
is defined as stacking two transducers (comp (map f) cat)
this seems interesting to solve baisc problems http://users.cecs.anu.edu.au/~steveb/downloads/pdf/rust-ismm-2016.pdf
Yeah, pretty sure GC will be the issue with rust. Coincidently I've been wondering about a clojure that targets golang, which has a pretty stellar GC and none of the oracle issues.
I asked recently on the off-topic channel but go no response — ClojureScript paved the way somewhat to have Clojure-on-Clojure, so I’m wondering if adding another runtime could now be easier?
GC and Jit must be handled, bit that's also true for must other non-jvm targets. I also see rust as a way to easy write c, so I don't get to closure to rust that well. Clojure to c would be nice, but has the same challenge for the GC.
@U26FJ5FDM: There's a dialect for Clojure on C++ that looks pretty interesting - https://ferret-lang.org/
Those wrappers look a lot more scary to me than Java interop, https://git.nakkaya.com/nakkaya/ferret-teensy-flight-sim/blob/master/core.clj#L12 and I have no c or c++ experience. One of the things I really like a about clojure is that you can use all the Java and clojure libraries. It would take a lot of work to get the same kind of thing without using the JVM. But it might also let things run faster and/or with less memory.
There’s a lot of brouhaha online about the recent licensing and schedule changes. There were a couple of articles on proggit/HN that Oracle will start to charge for LTS releases, based on a big misunderstanding of OracleJDK/OpenJDK, AFAICT.
what is the fastest way to convert a n-elem byte-array to a n-elem float-array ? (each byte becomes a float valued 0 -> 255.0)
I have a cljc
file in lein project and I have cljc
test for it in the test folder
Now I want to include cljc test in both clj and cljs test runners and see the results of the tests
to include and run cljc test in clj test runner, I have to compile it and :aot :all
doesn’t seem to work in the test folder
How do I compile the cljc file in test folder ?
@hiredman basically it tries to find a .class file with the same name, so I tried :aot :all
Now I get Caused by: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.regex.Pattern
clojure.test also doesn't load any namespaces, so you have to make sure the namespace is loaded before trying to run the tests in it
I tried (t/run-tests ’cljc-namespace) and it complains Caused by: java.lang.Exception: No namespace: cljc-namespace found
I have
(ns test-runner
(:require [clojure.test :as t :refer [is are deftest testing]]))
so you are not loading the cljc-namespace, so of course when you ask clojure.test to test it, it throws an error because the namespace you asked it to test doesn't exist (where exist here means exists in the clojure runtime, not exists like there is a file on disk that defines it)
you must load the definitions of tests first yourself before you can ask clojure.test to run the tests
I don't know the specifics of your situation, but it seems like you are a beginner, so some advice, don't use single segment namespaces like test-runner, instead use something like test.runner (the . is a segment separator). The reasoning for that is if you do aot compile a single segment namespace, you end up with a class in the default package which is usually considered kind of bad jvm citizenship
Thanks @hiredman for the clarification. However my namespace are in the format of x.runner, just changed it to not share the exact name
I did try (require ’cljs-namespace) and I now get Caused by: java.lang.IllegalAccessError: reader-error does not exist
likely you have errors in it (syntax, using defs from other namespaces you haven't referred, etc)
you may also have a bunch of stale class files left over from when you were aot compiling, which can really trip you up