This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-29
Channels
- # announcements (5)
- # beginners (25)
- # calva (53)
- # clj-kondo (9)
- # clojure (25)
- # clojure-europe (14)
- # clojure-nl (1)
- # clojure-norway (21)
- # clojure-uk (1)
- # conjure (2)
- # data-science (1)
- # datalevin (4)
- # datascript (6)
- # deps-new (5)
- # emacs (5)
- # etaoin (6)
- # figwheel-main (1)
- # fulcro (46)
- # gratitude (3)
- # hyperfiddle (8)
- # introduce-yourself (13)
- # lsp (13)
- # nextjournal (5)
- # off-topic (2)
- # pathom (4)
- # polylith (11)
- # re-frame (16)
- # releases (4)
- # scittle (67)
- # shadow-cljs (38)
- # slack-help (4)
- # specter (13)
- # sql (29)
- # squint (21)
- # test-check (3)
- # vim (13)
- # xtdb (15)
Added two new functions, looking pretty sweet if you ask me:
export function partial(f, ...xs) {
return function (...args) {
return f(...xs, ...args);
};
}
export function cycle(coll) {
return new LazyIterable(function* () {
while (true) yield* coll;
});
}

looking great. I was looking at the implementation of take-while and curious if there is any particular reason to use manual iterator rather than using for..of
or is it just preference.
@prabnz Changed it to:
export function take_while(pred, coll) {
return new LazyIterable(function* () {
for (const o of iterable(coll)) {
if (pred(o)) yield val;
else return;
}
});
}
wow, you are very fast. looks good.
also I am wondering if the minifiers actually minify code like new LazyIterable
. If not then maybe wrap it in a function to reduce code size.
also simplified drop-while
:
export function drop_while(pred, xs) {
return new LazyIterable(function* () {
let done_dropping = false;
for (const o of iterable(xs)) {
if (done_dropping) yield o;
else if (!pred(o)) {
yield o;
done_dropping = true;
}
}
});
}
yes, but I am not sure if it will help with minification. I will do some experimentation
yes, agree
Hmm, currently working on group-by
and this makes me wonder if it should return an object or map, by default. lodash returns an object with the stringified key, which probably works best for interop with the rest of the stuff, rather than returning a Map by default
OTOH, this should probably work, as in CLJS, so Map would make sense:
$ ./node_cli.js -e '(prn (get (group-by odd? [1 2 3 4]) true))'
["0","1","2","3"]
Haha, wow, I got bitten by JS twice in the last half an hour:
const o in [1,2,3,4] vs const o of [1,2,3,4]
and:
reusing a mutable array, so all vals in the group-by map were the same mutable collection:
const update_fn = (fnil conj_BANG_ [])
I guess I could have used conj
instead of conj_BANG
as well