This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-02
Channels
- # adventofcode (6)
- # announcements (6)
- # babashka (21)
- # babashka-sci-dev (18)
- # biff (6)
- # clara (4)
- # clj-commons (2)
- # clj-kondo (7)
- # cljdoc (4)
- # clojure (9)
- # clojure-berlin (8)
- # clojure-europe (23)
- # clojure-gamedev (3)
- # clojure-indonesia (1)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-poland (1)
- # clojurescript (27)
- # community-development (1)
- # conjure (32)
- # etaoin (6)
- # events (20)
- # fulcro (5)
- # graalvm (1)
- # helix (19)
- # hyperfiddle (14)
- # introduce-yourself (2)
- # music (1)
- # nbb (24)
- # off-topic (37)
- # pathom (2)
- # polylith (14)
- # reagent (11)
- # releases (1)
- # remote-jobs (1)
- # reveal (22)
- # shadow-cljs (16)
- # sql (3)
- # squint (11)
- # test-check (2)
- # xtdb (36)
I was doing Advent of Code 2021 part 1 and I came to an interesting discovery (after fixing some bugs and adding some core functions). The following gives the correct answer in nbb, but not using clavascript:
(ns aoc01
(:require ["fs" :as fs]))
(def input
(mapv js/parseInt (.split (.trim (str (fs/readFileSync "./input/aoc01.txt"))) "\n")))
(defn increases [nums]
(filter true?
(map #(< %1 %2)
nums
(rest nums))))
(def answer-01 (time (prn (count (increases input)))))
(def sums
(map #(+ % %2 %3) input (rest input) (rest (rest input))))
(def answer-02 (time (prn (count (increases sums)))))
It does work when I turn map into mapv. Something about re-using map lazy stuff not handled correctly.
I've made a start with clavascript/string.js
:
https://twitter.com/borkdude/status/1565690878710145026
Just pushed a change which addresses using namespace aliases and cleanly distinguishes those from core or user-defined vars:
$ ./node_cli.js --show -e '(ns foo (:require [clava.string :as str])) (defn split [x] x) (prn (str/split "foo,bar" ","))'
import { prn } from 'clavascript/core.js'
import { split as str_split } from 'clavascript/string.js'
var split = function (x) {
return x;
};
prn(str_split("foo,bar", ","));
export { split }
["foo","bar"]
Without importing * as
which some treeshakers do not play well withlooking around at the various JS runtimes that support ES Modules, and the state of "dynamically reloading code" is dire
a lot of open issues from 2-3 years ago with people saying "yeah the standard doesn't support this so we have to figure it out... at some point"
Now using clava.string in my aoc solution! :) https://github.com/clavascript/advent-of-code/commit/169a99b9672f7097ed93314d924a844c427dc69f