Fork me on GitHub
Mario C.00:08:48

found the error


what was it?

Mario C.00:08:20

The error was because the :plugins key value was incorrect. Just a single vector instead of each of plugin being its own vector

Mario C.00:08:35

pure luck I even caught this


wow, the dark side of pure data driven DSL

Mario C.00:08:21

lol this was a hard stuck for me


#beginners might not be the right place for this question ... but, I'm pulling in AsciidoctorJ (java bindings to a ruby gem called asciidoctor) through tools.deps and there's a gem that provides additional functionality ... is there a way to have tools.deps use JRuby to pull in the gem so it can be used?


@johnjelinek it looks like jruby is on maven, so you can pull it in as a dep, the next question is how to invoke it to make it pull in and run a gem


that might be more of a jruby question - I assume they have a java api, and if that exists clojure can use it via interop


for comparison, with clojure, you could depend on the lib via maven and it would in turn depend on clojure, allowing you to invoke clojure and run the lib


one would hope jruby allows something similar


So, it looks like AsciidoctorJ comes with an internal JRuby that can resolve gems, but those gems still have to get in there somewhere. I guess maybe there's a way to call the bundle install of JRuby from within the Clojure process?


hopefully JRuby provides a way to invoke that via interop, if so you can do it from Clojure


a brief google search makes it look like the jruby bundler isn't tied to maven at all, so tools.deps wouldn't do anything with it, but you could definitely script a bundler call into a build process that uses tools.deps to find clojure / maven depenencies


tools.deps intentionally isn't a building or packaging tool, it's just for finding jvm deps


on the other hand, lein does intend to be a packaging and building tool, and does have a plugin for jruby (I can't vouch for the quality)


I'm making a japanese learning application, right now I'm working on drills


So that I can test people for things in an automated way


Repeat it until you get >80% or whatever


{:は "Mr. Tanaka", :から "Japan", :verb "is."}


I have some example maps of potential sentences. The pairs of word+particle, represented in the map as matched :k "v" pairs can be in any order, as long as the verb's at the end.


Not all the maps have the same keys...


should I be striving to name all the keys in the map the same?


like :word1 :particle-for-word1


:word2 :particle-for-word2


or can I name them :particle1 word1 ... :particle2 :word2 ... not every map has every potential key i'd be using, just a small subset


@noisesmith: ya, I'm trying to not use lein as much as possible ... and I've been using tools.deps as my task runner with :aliases


@alexmiller: hey hey, I'm workin' through Clojure Applied. Page 53, I've run into an error:

user=> (take 5 (sort (map (:name planets))))
Execution error (IllegalArgumentException) at user/eval6461 (REPL:1).
Don't know how to create ISeq from: clojure.core$map$fn__5862


this works though:

user=> (take 5 (sort (map #(get % :name) planets)))                                                                     ("Earth" "Mars" "Venus") 


so does this:

user=> (take 5 (sort-by :name planets))                                                                                 ({:name "Earth"} {:name "Mars"} {:name "Venus"})


You have ( ) in the wrong place


(map :name planets) not (map (:name planets))


(map (:name planets)) tries to select the :name from the collection planets which will produce nil and then (map nil) is the 1-arg form which produces a transducer.


Hence the error: trying to create a ISeq (as the argument of sort) from that transducer (which is an anonymous function from inside map)


that's how it's written in the book

👍 4

Then it's wrong in the book.

🎯 4

user=> (take 5 (sort (map :name planets)))                                                                              ("Earth" "Mars" "Venus") 

Alex Miller (Clojure team)02:08:46

yeah, that's a bug in the book

😁 4

It's listed as a known issue in the errata:

Alex Miller (Clojure team)02:08:23

that's to check that you're reading closely

😆 8

Is there an editor that offers automatically adding imports in clojurescript? especially adding libraries from javascript like material-ui? It's killing me having to type manual requires in when I need to use a button or something.


how are you importing them? do you know of [my.lib :as m], allowing you to refer to them as m/button?


@UCW9TUDNK yup, what I'm hoping though is to not have to type any of that. I. typescript or kotlin when you use something from another library or package that you haven't written the import for, intellij will just automatically add the import for you. I'm pretty sure cursive can do this for Clojure, but not clojurescript


it would probably be best to ask this in the specific channel for your editor. (I recommend Cursive if you aren't attached to any specific one.) If it doesn't support this, a simple helper could be creating a snippet for the ns declaration that already includes the requires you usually type in.


or is this what the cljsjs projects are supposed to solve? providing namespaces and function definitions for javascript libraries?


sorry if this is a dumb question, but here we go: i have some values (in a list), where every one is one of a list of possible values (the status of a server, so "starting", "stopped", etc). These options have a specific order, and i need to find the entry in my value-list that comes first in the list of options. in java/kotlin, i would use enums for that, and have an enum entry for every option and then just sort. how do i go about doing this in Clojure? is there some idiomatic way to achieve this?


@lkowarschick you can do like this on Clojure, there is no enum like java on Clojure. All Clojure data structure (collections or map) is seq-able and you can iterate every element on it.


thanks for your time ;D my solution ended up being really simple:

(def states ["STOPPED" "STARTING" "RUNNING"])

(defn worst-status [stati]
  (first (filter #(.contains stati %) states)))

👍 4

After installing clj according to, I cannot get the REPL up. The clj command is unresponsive for a good minute and then spits out a big Java stacktrace, the key part is Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.clojure:clojure:pom:1.10.1 from/to central (): No route to host (Host unreachable)


I'm very certain this is due to corporate network proxy. What's the recommended way to tell clj about my proxy settings?

Alex Miller (Clojure team)13:08:47

you can use maven proxy settings


that did it, thanks!


does anyone have examples of passing specs to defrecord?

user=> (clojure.repl/doc defrecord)
([name [& fields] & opts+specs])
  (defrecord name [fields*]  options* specs*)

Alex Miller (Clojure team)16:08:22

Those specs are not spec specs

Alex Miller (Clojure team)16:08:59

Specs there are referring to protocol/interface implementations

Ashley Smith17:08:54

Hey, so I have a simple question. In Clojure, we use foo/core.clj(s) a lot. However, when it comes to dependencies, what are the best practices? Should foo/core.clj :require things in it's folder, or should it act as a common file intended to be included by others? I'm neatening my file structure today, and was wondering whether db/core.clj should contain common functions, or whether db/core.clj should act as a single thing to require that handles your things for you. Any ideas?


arguably the ubiquity of "core.clj" is just circumstantial - it's a default with lein templates because single segment namespaces are problematic and some generic name was needed


ideally you can have a namespace with a more meaningful name


that said, if present, people expect the "core" ns to be top level, I think

Ashley Smith17:08:12

I'm glad I chose right then 🙂 Thank you again!


the canonical example would be clojure.core (the top level clojure ns of clojure code, implicitly used if you use the ns macro to create a namespace)

Paulius Macernis18:08:37

Hi. Sorry if the question is dumb enough, I do try to learn here.. 🙂 I have a timestamp value which I got in the way like that let [timestamp (java.time.LocalDateTime/now). How do I format the value to something like yyyy-MM-dd'T'HH:mm:ss afterwards ?


java.time times usually use that kind of format as their default if you just call str or .toString on them


if you want to be explicit (.format (java.time.format.DateTimeFormatter/ISO_LOCAL_DATE_TIME) (java.time.LocalDateTime/now)) (I'm not familiar with java time yet but this seems to be a straight forward way. maybe someone more java interop-y than me can comment on how they'd do it


the parens around the ISO_LOCAL_DATE_TIME are optional btw, it's a field, not a method


I mean, (Math/PI) is valid too, but it's weird


ah thanks. i'm still bad at reading javadocsa

Paulius Macernis19:08:26

Thanks to all of you! However, I am still on figuring out how to "connect" the answer to my own needs (the test which is currently failing). At the moment I went to read some more info on the data/time in Java and Clojure. Hope to improve on the topic soon 🙂


none of this is Clojure specific (beyond interop syntax which applies to everything we get from Java)


which do you prefer: PersistentQueue or a channel?


the usage is very different


a pqueue is a value and a channel is not


so you can safely use a pqueue as a key for a map, or as part of the succession model


there are single threaded functional algorithms where you need a queue, and that is where you use a pqueue