Fork me on GitHub

hi guys, I'm trying to get REBL working in cursive ( intellij ) , I'm following this guide , but I'm stuck when setting the clojure REPL preferences in intelliJ, it displays "Run Configuration Error : No external project path found for ..."


any idea on how to fix it?


@vachichng You made need to ask in #cursive


@seancorfield thanks, got it working, I had to enable the alias in the clojure deps toolbar


Hi all, beginner here. The Clojure's default repl (by typing clojure in bash) doesn't support up arrow key for history and syntax highlighting. Is there a widely used better alternative to this default REPL?


for interactive programming at the command line, there's another shell script named clj (which is a readline wrapper around clojure command) that supports command line navigation/editing. you may also use which provides both an online editor (with syntax highlighting) and an online repl.


I'm mainly using a REPL for learning (e.g. following examples in a book)


something closer to Ipython would be great


That's pretty awesome @U883WCP5Z

๐Ÿ‘ 1

Happy Friday everyone! In spec, how would I specify that keys in a map should be the first items from a list? If the map has 1 kv pair, its key should be :player1, if the map has 2 kv pairs, the keys should be :player1 and :player2 etc.


I suppose, said another way, can I ensure that if :playerx is present, then :player1, :player2, ... :playerx must be?


functions can be specs, so if you can write a function to express that constraint you can use it as a spec


Cool, I'll work on that. I guess the function should return true where the check passes?


As a follow-up I presume I'll be best off writing a custom generator for this spec, since a random selection of keys is unlikely to fulfil this criterion


yes to both :thumbsup:

๐Ÿ˜Ž 1
Juliano Pereira Lima14:08:26

Hello. Does anyone know of a repository for a clojure console application that can serve as an example of folder organization, names, and separation of responsibilities?


hmm a clojure console application... i would say go through all the lein templates and do lein new [whatever] yourprojname and you'll be able to inspect from the console with tree or from the finder/file browser


i don't really know what you mean by clojure console app but i'm sure there is something similar to what you need, computers don't have that many output organs ๐Ÿ˜› could you elaborate on your end-goal?

Juliano Pereira Lima15:08:39

I am developing a project to build on some clojure concepts by reading a json file via stdin and doing some manipulation. I wanted some example of good folder structuring practices. I think my project is a little messy


@julianodgtz I'm not sure it would be that different from a standard application. You are going to have a main that gets executed when you run it from the CLI. Seems like it should be the standard src/project_name structure. Having said that, there are a couple of tools you should check out for helping to build the console application.

Juliano Pereira Lima15:08:26

thanks @U6SN41SJC o/. The organization of this project gave me good insights


Sure thing. Spammed the main thread with a few other things you might find useful. Let me know if you have any questions or whatever and good luck!

Mario C.15:08:09

I need some help with making my REPL driven development better. I am working on an API and when I run it locally I call lein run-server which starts the application and I can hit localhost:8080/mo/status and it responds with "ok". If I want to return "ready" instead, I make the changes and restart the server. I'd like to be able to start the app by starting a REPL and then navigating to the handler's namespace and calling the start method. Then whenever I make changes to one of the routes I can then re-evaluate the file and navigate to localhost:8080/mo/status and see "ready". The last sentence is where I am tripping up on. Since when I tried this, this did not work. Thinking about it I realized that, thats not how things work. I can't just load up a file into the REPL process and expect the app to reflect those changes as they are two different processes (right?). So my question is how can I set up a work flow like this?


That is the best lib I have come across for dealing with command line arguments and sub-commands.


@julianodgtz There are couple of things to help boost JVM startup speed, but unfortunately I can't find/remember their names. This was the only one I found but it hasn't been touched in a while so I'm not sure if it is still actively maintained:


@julianodgtz there's also which is an interesting alternative for creating cmd applications:

โค๏ธ 1

@U06BE1L6T That is pretty cool!


Lastly, lein-binplus is a handy lein plugin for generating executable JAR files and outputting them someplace on your class path.


@mario.cordova.862 Ring apps tend to wrap functions in middleware so they take the value of the function(s) when you start the app and you don't see redefinitions. The "trick" is to use #' to pass Vars instead so that they are still dereferenced (a bit slower) but will see changes.


So if your start function refers to app (your application/routes), change it to use #'app instead.


The same is true for your handlers in your route declarations. See and as examples of passing Vars instead of values, so that you can get live updates in the REPL for your running application.


Anyone know a library that has a function for getting leaf nodes in a directed graph? I don't see it in loom or ubergraph, but maybe I'm looking for the wrong thing? Using the wrong terminology? I can write it myself, but I feel like I'm duplicating work that's already been done.


with a common graph data format that should be a simple reduce (use a set of the node list as an accumulator, traverse the edges and remove origin nodes from the set)


I didn't actually think about it that way :thinking_face:


I was doing a product that fit naturally with a graph representation a while back, and found that the clj graph data libs were good for specific and relatively tricky algorithms from the graph theory cs literature but tended to lack simple data operations like this, and also lacked more advanced algorithms


so we had to do a lot ourselves, because it was either too simple for the graph libs or too tricky


If by 'leaf' you mean maybe it has some in-edges, but no out-edges, then yeah, you can iterate over all nodes and ubergraph (and probably also loom) has a function to return the list of out-edges, and/or a count of them.


called out-degree, IIRC


oh - d'oh you are right, thanks


Ah, thanks! I just now saw this.


can someone explain transit to me? i have a huge json dictionary file to parse and i want to do that.


unless it makes sense to parse xml with clojure o.O


If youโ€™re parsing json then you should probably use a json parser


Like cheshire or data.json


if xml, then data.xml


Better yet, how can I convert the xml to clojure data right out


okay thanks, i'll look at data.xml ... [the proj in question] is a popular open source japanese dictionary file called JMdict that has a common .gz XML and some ports to JSON and several small programs just to spit out a JSON version, i think sticking to the original XML is probably the way to go forward w/ highest fidelity, if I can figure it out I can push a clojure data version of the same jmdict


That sounds like a good idea ^, removing the unnecessary middle conversion (to json) if you want it in edn ultimately.

metal 1