Fork me on GitHub
#beginners
<
2019-08-23
>
Ludwig00:08:22

hi guys, I'm trying to get REBL working in cursive ( intellij ) , I'm following this guide https://github.com/cognitect-labs/REBL-distro/wiki/REBL-in-IntelliJ-Cursive , but I'm stuck when setting the clojure REPL preferences in intelliJ, it displays "Run Configuration Error : No external project path found for ..."

Ludwig00:08:26

any idea on how to fix it?

seancorfield01:08:44

@vachichng You made need to ask in #cursive

Ludwig01:08:18

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

zhuxun207:08:54

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?

salam07:08:33

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 https://repl.it/languages/clojure which provides both an online editor (with syntax highlighting) and an online repl.

zhuxun207:08:24

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

zhuxun207:08:04

something closer to Ipython would be great

zhuxun207:08:39

That's pretty awesome @U883WCP5Z

๐Ÿ‘ 4
Jazzer09:08:38

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.

Jazzer09:08:17

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

schmee09:08:12

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

Jazzer09:08:58

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

Jazzer09:08:46

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

schmee09:08:08

yes to both :thumbsup:

๐Ÿ˜Ž 4
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?

sova-soars-the-sora15:08:44

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

sova-soars-the-sora15:08:01

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

mafcocinco15:08:41

@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

mafcocinco15:08:13

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?

mafcocinco15:08:18

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

mafcocinco15:08:34

@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: https://github.com/ninjudd/drip

jumar04:08:05

@julianodgtz there's also which is an interesting alternative for creating cmd applications: https://github.com/candid82/joker

โค๏ธ 4
mafcocinco21:08:27

@U06BE1L6T That is pretty cool!

mafcocinco15:08:22

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

seancorfield18:08:12

@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.

seancorfield18:08:34

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

seancorfield18:08:13

The same is true for your handlers in your route declarations. See https://github.com/seancorfield/usermanager-example/blob/master/src/usermanager/main.clj#L108-L130 and https://github.com/seancorfield/usermanager-example/blob/master/src/usermanager/main.clj#L202 as examples of passing Vars instead of values, so that you can get live updates in the REPL for your running application.

bringe22:08:54

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.

noisesmith22:08:38

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)

bringe22:08:37

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

noisesmith22:08:37

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

noisesmith22:08:11

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

andy.fingerhut23:08:26

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.

andy.fingerhut23:08:32

called out-degree, IIRC

noisesmith23:08:02

oh - d'oh you are right, thanks

bringe00:08:05

Ah, thanks! I just now saw this.

sova-soars-the-sora22:08:29

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

sova-soars-the-sora22:08:44

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

Alex Miller (Clojure team)22:08:38

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

Alex Miller (Clojure team)22:08:01

Like cheshire or data.json

sova-soars-the-sora22:08:48

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

sova-soars-the-sora22:08:14

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

bringe22:08:55

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

metal 4