-
|
Hi everyone, I am new to this language and I cannot get why this doesn't work for squint: (ns day3
(:require [squint.string :as squint.string]))
; (:require [clojure.string]))
(warn-on-lazy-reusage!)
(def data-raw
"987654321111111
811111111111119
234234234234278
818181911112111")
(defn -combine [v-of-digits]
(for [el-of-v (range (count v-of-digits))
el-of-v-sub (range (inc el-of-v) (count v-of-digits))]
[(v-of-digits el-of-v) (v-of-digits el-of-v-sub)]
))
(defn digits->int
[digits]
(reduce (fn [acc el] (+ (* acc 10) el)) 0 digits))
(def joltage-total
(->> (squint.string/split-lines data-raw)
(map #(squint.string/trim %))
; (->> (clojure.string/split-lines data-raw)
; (map #(clojure.string/trim %))
(map #(mapv (comp parse-long str) %))
(map (comp #(apply max %) -combine))
(map digits->int)
(apply +)
))
(println joltage-total)where as it works as expected in clj/cljs. Getting: |
Beta Was this translation helpful? Give feedback.
Answered by
borkdude
Dec 4, 2025
Replies: 1 comment 6 replies
-
|
@mrsipan Hey, welcome. The issue is that you are passing an array as function. In CLJS these are vectors and usable as functions but in squint they aren't. So you can use |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
mrsipan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mrsipan Hey, welcome.
The issue is that you are passing an array as function. In CLJS these are vectors and usable as functions but in squint they aren't. So you can use
(get v-of-digits el-of-v)instead.https://squint-cljs.github.io/squint/?src=gzip%3AH4sIAAAAAAAAE3VS207jMBB9z1ccQEg2yEBbFlqQ%2BiNRHoZkGrly7GA7Zbtfj0wgOGVx8pI5l8kcj7ABDR1XBSCePL8O2jPK8DpoG29C9Nq2eKKAWaWSsgCec0Vt3H7wnBEK8UbeKmeVoX9H5XkI1PJZAhreoaFIytNbAZxv1o8Pf%2B5Xy8V4CgDrRX42qbRc3X%2B%2Fj%2BuRlZ5NoiTx%2Bae5hapd96Itozwot1ONbnUMVRpyH25rZ4MzfGNciwyWRcJ3zqNkk8oHCE%2B2ZYjaDTbOuCmA8XxyVRheJr629Vdd%2FlddpV4oRcszIBP9gqQ2svpoLqdpR4raahsLoMym9dwMNUPsLEqq009VENcQV0hfizsJNlLiDtNY4%2B3snYnUsooukklGaruFmC3BbeiNjspoy2G6zSkW0VGPixNF9LrD…