Fork me on GitHub
#calva
<
2020-12-08
>
practicalli-johnny11:12:34

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

practicalli-johnny11:12:51

@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

practicalli-johnny12:12:43

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?

bringe19:12:43

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.

👍 3
practicalli-johnny16:12:51

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.

ryan echternacht22:12:22

I've written (and executed) a few infinite loops recently. How can I get calva to stop executing?

ryan echternacht22:12:42

I've had to kill vscode, which doesnt seem like it should be necessary. Even just killing the repl woudl work

pez22:12:53

Advent of Code much? 😃

pez22:12:14

Try the Interrupt Running Evaluations command. Sometimes you need to do it twice.

3
ryan echternacht22:12:03

Yes it was advent of code 😛

pez22:12:42

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.

ryan echternacht15:12:14

oh you (tryin a be) fancy

ryan echternacht15:12:38

I just brute forced it. god bless clj being really good at making a bunch of "clones" of a map cheaply and easily

pez16:12:09

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

pez16:12:13

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.

ryan echternacht16:12:00

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)))

ryan echternacht16:12:07

then ran all of those.

ryan echternacht16:12:18

And yeah, I noticed the infinite printing issue ^^

pez16:12:36

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))

pez16:12:16

> (#(repeat (count %) %)) 😂