This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-01
Channels
- # adventofcode (30)
- # announcements (51)
- # aws (27)
- # babashka (1)
- # beginners (16)
- # calva (6)
- # cider (10)
- # clj-kondo (2)
- # clojure (94)
- # clojure-dev (27)
- # clojure-italy (1)
- # clojure-taiwan (1)
- # clojure-uk (5)
- # clojurescript (18)
- # clojutre (2)
- # cursive (14)
- # data-science (8)
- # emacs (2)
- # joker (5)
- # off-topic (3)
- # shadow-cljs (31)
- # sql (2)
- # vim (2)
- # yada (11)
Let's say I want to set up a Leiningen project for Project Euler problems and I want to do lein run [number]
to run any solution but I also want each solution in its own file. What's the best way to set that up in the code? I just need a general idea.
@readyready15728 lein run
runs the -main
function in the :main
namespace of the project. Everything after that (such as number
in your case) is a command line argument, passed as a string to the -main
function (which takes [& args]
so (first args)
would be the string of the number).
Your -main
could take that string and load the corresponding file if you follow a convention.
I don't know what your Euler problem files would look like. I don't believe you can have just a number as the filename or namespace so you'll need some prefix on the number, maybe e
for Euler?
Does that give you enough hints and tips to point you in the right direction?
If you look at the site they have several hundred problems so I would loading 001.clj
, 002.clj
, 003.clj
etc. I just want to know what's a good way to do that from -mein
.
Errr, -main
Simpler than I thought
How I can add item to tree?
(def tree {
:r {
:v "b"
:r nil
:l nil
}
:l nil
:v "a"
})
(insert tree :r "c") =>
{
:r {
:v "b"
:r {
:v "c"
:r nil
:l nil
}
:l nil
}
:l nil
:v "a"
}
I think about loop-recur, but I can’t understand how to return head of tree at the end of loopIt's not entirely clear to me how you expect (insert tree :r "c")
to behave. Here, you're inserting "c" under [:r :r]
, not [:r]
. Could you explain in more detail?
@codonnell I’ll expecting that insert
create node in the first :r
which be equal nil
In that case, I would personally use loop-recur to find the depth of that node and use the depth to do something like (assoc-in tree (vec (repeat depth :r)) {:v "c" :r nil :l nil})
Does it efficient solution?
is anyone running cursive on 2019.3? I'm getting this warning: https://i.imgur.com/5lBu3Ng.png