@pez the error only happens when using jack-in from Calva though, the alias works just fine on the command line on the same machine and setup. So something between Calva and tools.deps maybe? I will test with more aliases as I have many that have kebab case and haven't experience this issue before.
@brandon.ringe The line of code you refer to has not changed in 14 months, so doubt there does not seem to be a difference in tools.deps.alpha library versions, unless you are using an unreleased version or using it directly from source. I am using Clojure CLI tools version "1.10.1.727" on Java 11 / Ubuntu 20.10
Update: the error only occurs when using jack-in from Calva with calva.replConnectSequences
so for now I will just suggest people copy any kebab-named aliases from practicalli/clojure-deps-edn into the project deps.edn file and avoid custom repl connect sequences
Unless there is another way to use user-level aliases with Calva jack-in without adding a custom replConnectSequences config?
Oh I see. Is it actually not loading the alias, or just a warning? I'll defer to @pez on the above question. If you create an issue we can track this for later.
I'll do a bit more testing and report an issue as detailed as I can. It certainly feels like an edge case that I'd like to understand clearly before creating an issue.
I've written (and executed) a few infinite loops recently. How can I get calva to stop executing?
I've had to kill vscode, which doesnt seem like it should be necessary. Even just killing the repl woudl work
Advent of Code much? π
Try the Interrupt Running Evaluations command. Sometimes you need to do it twice.
Yes it was advent of code π
oh you (tryin a be) fancy
I just brute forced it. god bless clj being really good at making a bunch of "clones" of a map cheaply and easily
I wasnβt consciously trying to make anything fancy. It just appeared to me as a tree problem and I went that way, never to return. Then when it was getting late here I gave up, made as many programs as there were input lines and modified them all. π
Interrupting infinit loops was a big part of what I was doing, btw. Turns out that if you print from an infinit loop you still have to reload the VS Code window, because it queues up so many printings that it never stops with that.
Oh. I read in the input. then just did something like
(map (fn [instructions]
(for [i (range (count instructions))]
// get line i; flip jmp <=> nop
// replace line i with the new line i)))
then ran all of those.
And yeah, I noticed the infinite printing issue ^^
We are both cloning the program, I just do it a bit more explicitly. Hereβs the whole thing:
(defn parse [input]
(->> (clojure.string/split-lines input)
(map #(clojure.string/split % #" "))
(mapv (fn [[op arg]] [op (Integer/parseInt arg)]))))
(defn run [program]
(let [length (count program)]
(reduce (fn [cpu _]
(let [{:keys [pc pcs]} cpu]
(if (< pc length)
(let [[op arg] (nth program pc)]
(if (pcs pc)
(reduced cpu)
(cond-> cpu
(= op "acc") (update :acc #(+ % arg))
(#{"acc" "nop"} op) (update :pc inc)
(= op "jmp") (update :pc #(+ % arg))
:always (update :pcs conj pc))))
(reduced cpu))))
{:acc 0
:pc 0
:length (count program)
:pcs #{}}
(range))))
(comment
(def input (util/fetch-input 8))
; step 1
(->> input
(parse)
(run)
:acc)
; step 2
(->> input
(parse)
(#(repeat (count %) %))
(keep-indexed (fn [i program]
(let [[op arg] (program i)]
(assoc program i [(cond
(= "nop" op) "jmp"
(= "jmp" op) "nop"
:else op)
arg]))))
(map run)
(filter #(= (:pc %) (:length %)))
(first)
:acc))
> (#(repeat (count %) %))
π
ah thanks!
Step 2 of day 8 nearly drove me crazy. But then decided to brute force it. Will go to bed defeated tonight, but at least I have collected the gold stars.