Fork me on GitHub
#squint
<
2023-12-06
>
pez10:12:05

clojure.set is not supported, yet, I take it?

TypeError: Failed to resolve module specifier 'clojure.set'

borkdude10:12:06

currently not, what function were you looking for, intersection?

borkdude10:12:17

in squint or cherry?

borkdude10:12:10

I have written intersection like this:

(defn intersection [& xs]
  (reduce (fn [acc s]
            (set (filter #(.has acc %) s))) xs))

pez10:12:24

Thanks. Yes, intersection. I tried both squint and cherry 😃

borkdude10:12:20

for cherry:

(defn intersection [& xs]
  (reduce (fn [acc s]
            (set (filter #(contains? acc %) s))) xs))

borkdude10:12:37

issue(s) welcome

pez10:12:09

TypeError: acc.has is not a function

pez10:12:14

No, I need to call it with sets of course. Never mind me. 😃

borkdude10:12:41

this is in squint right

borkdude10:12:49

please confirm so we're not talking across each other

borkdude10:12:59

in cherry you can just use normal sets

borkdude10:12:10

no need to call .has , this is for native sets, in squint

borkdude10:12:40

I wrote contains?

pez10:12:25

I see. The function works in Cherry if I call it like so:

(intersection (set [1 2 3]) (set [1 2]))

pez10:12:40

Will try this one.

borkdude10:12:55

ah yes, in general you always need to call set functions in clojure.set with sets, not other collections

borkdude10:12:01

this is a known issue

pez10:12:18

I run into troubles with both parts of my day 4 solution. http://localhost:8090/?repl=true&amp;boilerplate=https%3A%2F%2Fgist.githubusercontent.com%2Fborkdude%2Fcf94b492d948f7f418aa81ba54f428ff%2Fraw%2Fa6e9992b079e20e21d753e8c75a7353c5908b225%2Faoc_ui.cljs&amp;src=OzsgSGVscGVyIGZ1bmN0aW9uczoKOzsgKGZldGNoLWlucHV0IHllYXIgZGF5KSAtIGdldCBBT0MgaW5wdXQKOzsgKGFwcGVuZCBzdHIpIC0gYXBwZW5kIHN0ciB0byBET00KOzsgKHNweSB4KSAtIGxvZyB4IHRvIGNvbnNvbGUgYW5kIHJldHVybiB4CgooZGVmbiBpbnRlcnNlY3Rpb24gWyYgeHNdCiAgKHJlZHVjZSAoZm4gW2FjYyBzXQogICAgICAgICAgICAoc2V0IChmaWx0ZXIgI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FyZF0KICAoaW5jIChyZWR1Y2UgKyAobWFwIChwYXJ0aWFsIGdldC1jb3VudCBjYXJkLT5jb2xsZWN0cykgKGNhcmQtPmNvbGxlY3RzIGNhcmQpKSkpKQoKKGRlZm4gY291bnQtY2FyZHMgW2NhcmQtPmNvbGxlY3RzXQogIChyZWR1Y2UgKyAobWFwIChwYXJ0aWFsIGdldC1jb3VudCBjYXJkLT5jb2xsZWN0cykgKGtleXMgY2FyZC0%2BY29sbGVjdHMpKSkpCgooY29tbWVudAogKGRlZiBleGFtcGxlLWlucHV0LTIgZXhhbXBsZS1pbnB1dC0xKQogKGRlZiBjb2xsZWN0aW9uICgtPj4gZXhhbXBsZS1pbnB1dC0yCiAgICAgICAgICAgICAgICAgICAgICBwYXJzZS1jYXJkcwogICAgICAgICAgICAgICAgICAgICAgKGludG8ge30gKG1hcCAoanV4dCA6Y2FyZCA6Y29sbGVjdHMpKSkpKQogY29sbGVjdGlvbiA6PSB7MSBbMiAzIDQgNV0sIDIgWzMgNF0sIDMgWzQgNV0sIDQgWzVdLCA1IFtdLCA2IFtdfQogKGNvdW50LWNhcmRzIGNvbGxlY3Rpb24pIDo9IDMwCiA6cmNmKQoKCihkZWZuIHBhcnQtMiBbaW5wdXRdCiAgKC0%2BPiBpbnB1dAogICAgICAgcGFyc2UtY2FyZHMKICAgICAgIChpbnRvIHt9IChtYXAgKGp1eHQgOmNhcmQgOmNvbGxlY3RzKSkpCiAgICAgICBjb3VudC1jYXJkcykpCgooY29tbWVudAogKHBhcnQtMiBleGFtcGxlLWlucHV0LTIpIDo9IDMwCiAoY29tbWVudAogICAodGltZQogICAgKHBhcnQtMiBteS1pbnB1dCkpCiAgIDpyY2YpKQ%3D%3D.

borkdude10:12:09

thank you for pasting a localhost link which I have open in squint 😆

😂 1
pez10:12:45

part 1 I just get undefined. For part 2 I get card__GT_collects is not a function

borkdude10:12:21

have you tried the smaller parts? when I evaluate:

(parse-card 4 "Card 1: 41 48 83 86 17 | 83 86  6 31 17  9 48 53")

borkdude10:12:31

it crashes with:

Error: function (_PERCENT_1) {
return globalThis.user.str.split.call(null, _PERCENT_1, / +/)
} is not ISeqable

borkdude10:12:49

(set #(str/split % #" +"))

borkdude10:12:10

it seems there is a bug, try out the smaller pieces before the whole solution

borkdude10:12:20

after fixing that bug, #(set (str/split ..) it works

pez10:12:03

I didn’t get that error…

pez10:12:38

I’m also confusing myself testing in both Cherry and Squint. I’ll try to stay with Cherry testing now first.

borkdude10:12:00

https://squint-cljs.github.io/cherry/?repl=true&amp;boilerplate=https%3A%2F%2Fgist.githubusercontent.com%2Fborkdude%2Fcf94b492d948f7f418aa81ba54f428ff%2Fraw%2Fa6e9992b079e20e21d753e8c75a7353c5908b225%2Faoc_ui.cljs&amp;src=OzsgSGVscGVyIGZ1bmN0aW9uczoKOzsgKGZldGNoLWlucHV0IHllYXIgZGF5KSAtIGdldCBBT0MgaW5wdXQKOzsgKGFwcGVuZCBzdHIpIC0gYXBwZW5kIHN0ciB0byBET00KOzsgKHNweSB4KSAtIGxvZyB4IHRvIGNvbnNvbGUgYW5kIHJldHVybiB4CgooZGVmbiBpbnRlcnNlY3Rpb24gWyYgeHNdCiAgKHJlZHVjZSAoZm4gW2FjYyBzXQogICAgICAgICAgICAoc2V0IChmaWx0ZXIgIyhjb250YWlucz8gYWNjICUpIHMpKSkgeHMpKQoKKGNvbW1lbnQKICAoaW50ZXJzZWN0aW9uIChzZXQgWzEgMiAzXSkgKHNldCBbMSAyXSkpCiAgKQoKOzsgUmVtZW1iZXIgdG8gdXBkYXRlIHRoZSB5ZWFyIGFuZCBkYXkgaW4gdGhlIGZldGNoLWlucHV0IGNhbGwuCihkZWYgaW5wdXQgKC0%2BPiAoanMtYXdhaXQgKGZldGNoLWlucHV0IDIwMjMgNCkpCiAgICAgICAgICAgICAjX3NweQogICAgICAgICAgICAgc3RyL3NwbGl0LWxpbmVzKSkKCihkZWYgZXhhbXBsZS1pbnB1dC0xCiAgWyJDYXJkIDE6IDQxIDQ4ID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ICAgICAgICAgICAgICAgICAgICBwYXJzZS1jYXJkcwogICAgICAgICAgICAgICAgICAgICAgKGludG8ge30gKG1hcCAoanV4dCA6Y2FyZCA6Y29sbGVjdHMpKSkpKQogY29sbGVjdGlvbiA6PSB7MSBbMiAzIDQgNV0sIDIgWzMgNF0sIDMgWzQgNV0sIDQgWzVdLCA1IFtdLCA2IFtdfQogKGNvdW50LWNhcmRzIGNvbGxlY3Rpb24pIDo9IDMwCiA6cmNmKQoKCihkZWZuIHBhcnQtMiBbaW5wdXRdCiAgKC0%2BPiBpbnB1dAogICAgICAgcGFyc2UtY2FyZHMKICAgICAgIChpbnRvIHt9IChtYXAgKGp1eHQgOmNhcmQgOmNvbGxlY3RzKSkpCiAgICAgICBjb3VudC1jYXJkcykpCgooY29tbWVudAogKHBhcnQtMiBleGFtcGxlLWlucHV0LTIpIDo9IDMwCiAoY29tbWVudAogICAodGltZQogICAgKHBhcnQtMiBteS1pbnB1dCkpCiAgIDpyY2YpKQ%3D%3D

borkdude10:12:32

in squint, collections are just native JS collections and they do not work as functions in call position

👍 1
borkdude10:12:44

so (def x #{1 2 3}) (x 1) doesn't work

borkdude10:12:28

https://squint-cljs.github.io/squint/?repl=true&amp;boilerplate=https%3A%2F%2Fgist.githubusercontent.com%2Fborkdude%2Fcf94b492d948f7f418aa81ba54f428ff%2Fraw%2Fa6e9992b079e20e21d753e8c75a7353c5908b225%2Faoc_ui.cljs&amp;src=OzsgSGVscGVyIGZ1bmN0aW9uczoKOzsgKGZldGNoLWlucHV0IHllYXIgZGF5KSAtIGdldCBBT0MgaW5wdXQKOzsgKGFwcGVuZCBzdHIpIC0gYXBwZW5kIHN0ciB0byBET00KOzsgKHNweSB4KSAtIGxvZyB4IHRvIGNvbnNvbGUgYW5kIHJldHVybiB4CgooZGVmbiBpbnRlcnNlY3Rpb24gWyYgeHNdCiAgKHJlZHVjZSAoZm4gW2FjYyBzXQogICAgICAgICAgICAoc2V0IChmaWx0ZXIgIyhjb250YWlucz8gY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jZikp but part 2 runs into the collection as function problem

pez10:12:27

Thanks. I think the editor must have nuked the hash in front of (set ... there. No idea when that happened.

pez11:12:22

I don’t see where I call the collection?

borkdude11:12:21

I already tried to fix it in some places, look at your old input

borkdude11:12:42

I discovered a few edge cases in squint, e.g. (reduce + []) returns undefined instead of 0

borkdude11:12:55

and I added bit-shift-left in the playground, it wasn't in squint yet

borkdude11:12:03

stil working towards a working solution for pt 2

borkdude11:12:33

https://squint-cljs.github.io/squint/?repl=true&amp;boilerplate=https%3A%2F%2Fgist.githubusercontent.com%2Fborkdude%2Fcf94b492d948f7f418aa81ba54f428ff%2Fraw%2Fa6e9992b079e20e21d753e8c75a7353c5908b225%2Faoc_ui.cljs&amp;src=OzsgSGVscGVyIGZ1bmN0aW9uczoKOzsgKGZldGNoLWlucHV0IHllYXIgZGF5KSAtIGdldCBBT0MgaW5wdXQKOzsgKGFwcGVuZCBzdHIpIC0gYXBwZW5kIHN0ciB0byBET00KOzsgKHNweSB4KSAtIGxvZyB4IHRvIGNvbnNvbGUgYW5kIHJldHVybiB4CgooZGVmbiBpbnRlcnNlY3Rpb24gWyYgeHNdCiAgKHJlZHVjZSAoZm4gW2FjYyBzXQogICAgICAgICAgICAoc2V0IChmaWx0ZXIgIyhjb250YWlucz8gYWNjICUpIHMpKSkgeHMpKQoKKGNvbW1lbnQKICAoaW50ZXJzZWN0aW9uIChzZXQgWzEgMiAzXSkgKHNldCBbMSAyXSkpCiAgKQoKOzsgUmVtZW1iZXIgdG8gdXBkYXRlIHRoZSB5ZWFyIGFuZCBkYXkgaW4gdGhlIGZldGNoLWlucHV0IGNhbGwuCihkZWYgaW5wdXQgKC0%2BPiAoanMtYXdhaXQgKGZldGNoLWlucHV0IDIwMjMgNCkpCiAgICAgICAgICAgICAjX3NweQogICAgICAgICAgICAgc3RyL3NwbGl0LWxpbmVzKSkKCihkZWYgZXhhbXBsZS1pbnB1dC0xCiAgWyJDYXJkIDE6IDQxIDQ4IDgzIDg2IDE3IHwgODMg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3VudCBjYXJkLT5jb2xsZWN0cykKICAgICAgICAgICAgICAgIChrZXlzIGNhcmQtPmNvbGxlY3RzKSkpKQoKKGNvbW1lbnQKICAoZGVmIGV4YW1wbGUtaW5wdXQtMiBleGFtcGxlLWlucHV0LTEpCiAgKGRlZiBjb2xsZWN0aW9uICgtPj4gZXhhbXBsZS1pbnB1dC0yCiAgICAgICAgICAgICAgICAgICAgcGFyc2UtY2FyZHMKICAgICAgICAgICAgICAgICAgICAoaW50byB7fSAobWFwIChqdXh0IDpjYXJkIDpjb2xsZWN0cykpKSkpCiAgY29sbGVjdGlvbiA6PSB7MSBbMiAzIDQgNV0sMiBbMyA0XSwzIFs0IDVdLDQgWzVdLDUgW10sNiBbXX0KICAoc3B5IChnZXQtY291bnQgY29sbGVjdGlvbiAxKSkKICAoY291bnQtY2FyZHMgY29sbGVjdGlvbikgOj0gMzAKICAocmVkdWNlICsgMCBbXSkKICA6cmNmKQoKCihkZWZuIHBhcnQtMiBbaW5wdXRdCiAgKC0%2BPiBpbnB1dAogICAgcGFyc2UtY2FyZHMKICAgIChpbnRvIHt9IChtYXAgKGp1eHQgOmNhcmQgOmNvbGxlY3RzKSkpCiAgICBjb3VudC1jYXJkcykpCgooY29tbWVudAogIChwYXJ0LTIgZXhhbXBsZS1pbnB1dC0yKSA6PSAzMAogIChjb21tZW50CiAgICAodGltZQogICAgICAocGFydC0yIG15LWlucHV0KSkKICAgIDpyY2YpKQ%3D%3D

borkdude11:12:32

now on to the squint bugfixes :)

pez11:12:08

What did you do to get part-2 work?

pez11:12:20

It works for my input data as well. 😃

borkdude11:12:11

I needed to fix reduce + 0

borkdude11:12:22

instead of reduce +

pez16:12:51

As for reductions. Is this fine, or is the unDRYness horrible?

export function reductions(f, arg1, arg2) {
  f = toFn(f);
  let coll, val;
  if (arg2 === undefined) {
    // (reduce f coll)
    const iter = iterable(arg1)[Symbol.iterator]();
    const vd = iter.next();
    if (vd.done) {
      val = f();
    } else {
      val = vd.value;
    }
    coll = iter;
  } else {
    // (reduce f val coll)
    val = arg1;
    coll = iterable(arg2);
  }
  if (val instanceof Reduced) {
    return val.value;
  }
  const vals = [];
  for (const x of coll) {
    val = f(val, x);
    if (val instanceof Reduced) {
      val = val.value;
      vals.push(val);
      break;
    } else {
      vals.push(val);
    }
  }
  return vals;
}

pez16:12:19

Looking at clojure.core/reductions maybe it points me in another direction…

borkdude16:12:27

I'll take a look after dinner

🙏 1
pez17:12:09

Trying to port reductions from clojure.core I get this:

export function reductions(f, arg1, arg2) {
  f = toFn(f);
  let ret;
  if (arg2 === undefined) {
    // (reductions f coll)
    if (arg1.length > 0) {
      ret = reductions(f, first(arg1), rest(arg1));
    } else {
      ret = list(f());
    }
    return new LazySeq(ret);
  } else {
    // (reductions f val coll)
    if (arg1 instanceof Reduced) {
      return list(arg1.value);
    }
    if (arg2.length > 0) {
      ret = reductions(f, first(arg2), rest(arg2));
    } else {
      ret = list(f());
    }
    return cons(arg1, new LazySeq(ret));
  }
}
But neither cons, nor LazySeq is printed nicely enough in the playground:
(reductions + [1 2 3])
=>
LazySeq {
  f: Cons { x: 1, coll: LazySeq { f: [List], res: undefined } },
  res: undefined
}

(reductions + 7 [1 2 3])
=>
Cons {
  x: 7,
  coll: LazySeq { f: Cons { x: 1, coll: [LazySeq] }, res: undefined }
}
Basically I don’t know if I am even close. 😃

pez17:12:49

OK, so I went closer to clojure.core’s implementation and now have this:

export function reductions(f, arg1, arg2) {
  f = toFn(f);
  if (arg2 === undefined) {
    // (reductions f coll)
    const s = seq(arg1);
    return lazy(function* () {
      for (const x of iterable(s ? reductions(f, first(s), rest(s)) : list(f()))) {
        yield x;
      }
    });
  } else {
    // (reductions f val coll)
    if (arg1 instanceof Reduced) {
      return list(arg1.value);
    }
    const s = seq(arg2);
    return cons(arg1, lazy(function* () {
      let ret = s ? reductions(f, f(arg1, first(s), rest(s))) : null;
      for (const x of iterable(ret)) {
        yield x;
      }
    }));
  }
}
Which is maybe a bit closer, but not quite right yet:
reductions + [1 2 3])
=>
LazyIterable(1) [
  [
    List(1) [ 1 ],
    List(1) [ '3' ],
    List(1) [ '0' ],
    List(1) [ '0' ],
    List(1) [ '0' ],
    List(1) [ '0' ],
    List(1) [ '0' ],
    List(1) [ '0' ],
    List(1) [ '0' ],
    List(1) [ '0' ],
    '...'
  ]
]
I’ll chill a bit with this until you have told me if it looks like I should keep trying. 😃

borkdude18:12:42

I'm fine with adding that as long as the tests pass :)

pez18:12:40

OK. I’ll keep at it until tests pass. 😃 I’ll let you know if I give up.

borkdude18:12:00

what test does not pass for example?

pez18:12:00

There are no tests for reductions. So I will have to write them first to tell you. I am guessing that for the non-DRY version the tests would pass. But for the more sensible implementation no tests would pass right now.

pez18:12:16

If that makes sense. Dinner time here. ttfn

borkdude18:12:50

I usually go to clojure-docs to steal some examples

borkdude18:12:46

one failing test case: (vec (reductions + [1 1 1 1]))

Cora (she/her)19:12:51

I've looked at the clojurescript source for some things but I feel like this must not be much different than the jvm version https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L10278-L10292

Cora (she/her)19:12:39

yeah, scratch that, they're identical

pez19:12:15

Indeed. Such a sweet language!

1
pez20:12:03

I don’t know why people find parens in Clojure tricky. What is truly tricky is parens in JavaScipt… Anyway, this works:

function* _reductions(f, arg1, arg2) {
  console.log('reductions', arg1, arg2);
  const init = arg2 === undefined ? undefined : arg1;
  const coll = arg2 === undefined ? arg1 : arg2;
  if (init === undefined) {
    // (reductions f coll)
    const s = seq(coll);
    yield* lazy(function* () {
      const ret = s ? _reductions(f, first(s), rest(s)) : list(f());
      for (const x of iterable(ret)) {
        yield x;
      }
    });
  } else {
    // (reductions f val coll)
    if (init instanceof Reduced) {
      return list(init.value);
    }
    const s = seq(coll);
    yield* cons(init, lazy(function* () {
      if (s) {
        for (const x of iterable(_reductions(f, f(init, first(s)), rest(s)))) {
          yield x;
        }
      }
    }));
  }
}

export function reductions(f, arg1, arg2) {
  f = toFn(f);
  return _reductions(f, arg1, arg2);
}
Where “works” so far means:
(reductions + []) => Object [Generator] {}
(vec (reductions + [])) => [ 0 ]
(vec (reductions + [1 1 1 1])) => [ 1, 2, 3, 4 ]
(vec (reductions get-counts '() counts)) ; from my day 4, part 2
=>
[
  List(0) [],
  List(1) [ 1 ],
  List(2) [ 1, 1 ],
  List(3) [ 2, 1, 1 ],
  List(4) [ 4, 2, 1, 1 ],
  List(5) [ 7, 4, 2, 1, 1 ],
  List(6) [ 15, 7, 4, 2, 1, 1 ]
]

Cora (she/her)20:12:30

I don't think they find parens tricky as much as in an unfamiliar position, and what really throws them off is how many keywords are missing in a way that's unique to lisps. things like while/then/end/fi/else/etc aren't there and that's what they usually use as landmarks to grok code -- instead in lisps everything is a parens so it it's a lot harder to parse at first

👍 1
Cora (she/her)20:12:59

I know that was a throwaway joke on your part but it's something i've been thinking about 😅

😂 1
pez20:12:37

Damn. This test fails:

(is (eq [0 1 3 3] (jsv! '(vec (reductions #(if (< %2 3)
                                             (+ %1 %2)
                                             (reduced %1))
                                          (range 5)))))
    "reduced early")
The last 3 is missing…
FAIL in (reductions-test) (squint/compiler_test.cljs:953:9)
no val
reduced early
expected: (eq [0 1 3 3] (jsv! (quote (vec (reductions (fn* [p1__73613# p2__73612#] (if (< p2__73612# 3) (+ p1__73613# p2__73612#) (reduced p1__73613#))) (range 5))))))
  actual: (not (eq [0 1 3 3] #js [0 1 3]))

borkdude20:12:58

Have you tried compiling the clojure version with squint and using that JS?

pez21:12:43

If I clean it up a bit, it works and passes the test that my version fails with:

export const reductions = (function () {
  let f19 = (function (var_args) {
 let G__221 = arguments.length;
 switch (G__221) {case 2:
 return f19.cljs$core$IFn$_invoke$arity$2((arguments[0]), (arguments[1]))
 break;
 case 3:
 return f19.cljs$core$IFn$_invoke$arity$3((arguments[0]), (arguments[1]), (arguments[2]))
 break;
 default:
 throw new Error(str("Invalid arity: ", alength(arguments)))}
 });
 f19.cljs$core$IFn$_invoke$arity$2 = (function (f, coll) {
 return new LazySeq((function () {
 let temp__27058__auto__3 = seq(coll);
 if (truth_(temp__27058__auto__3)) {
 let s4 = temp__27058__auto__3;
 return reductions(f, first(s4), rest(s4))} else {
 return list(f())}
 }))
 });
 f19.cljs$core$IFn$_invoke$arity$3 = (function (f, init, coll) {
 if (truth_(reduced_QMARK_(init))) {
 return list(deref(init))} else {
 return cons(init, new LazySeq((function () {
 let temp__27136__auto__5 = seq(coll);
 if (truth_(temp__27136__auto__5)) {
 let s6 = temp__27136__auto__5;
 return reductions(f, f(init, first(s6)), rest(s6))}
 })))}
 });
 f19.cljs$lang$maxFixedArity = 3;
 return f19
 })();

borkdude21:12:29

Then maybe let's take that version and clean it into readable JS

pez21:12:50

It returns new LazySeq instead of a generator. Is that fine?

borkdude21:12:38

let's remove the cljs$core$Ifn junk too

borkdude21:12:45

and just make it like reduce is

pez21:12:22

I’ll see if I can figure out my bug with this code.

pez21:12:22

If I change my hand-ported one to return LazySeq instead of being a generator, then it passes my current tests:

function _reductions(f, arg1, arg2) {
  const init = arg2 === undefined ? undefined : arg1;
  const coll = arg2 === undefined ? arg1 : arg2;
  if (init === undefined) {
    // (reductions f coll)
    const s = seq(coll);
    return new LazySeq(function () {
      return s ? _reductions(f, first(s), rest(s)) : list(f());
    });
  } else {
    // (reductions f val coll)
    if (reduced_QMARK_(init)) {
      return list(init.value);
    }
    const s = seq(coll);
    return cons(init, new LazySeq(function () {
      if (s) {
        return _reductions(f, f(init, first(s)), rest(s));
      }
    }));
  }
}
Why that makes a difference for the reduced test is beyond me, but if we are good with returning this, I am happy.

borkdude21:12:41

yep, looks amazing

borkdude21:12:13

the two bodies look almost identical though

pez21:12:15

I made it a tad more readable like so:

function _reductions(f, arg1, arg2) {
  const [init, coll] = arg2 === undefined ? [undefined, arg1] : [arg1, arg2];
  const s = seq(coll);
  if (init === undefined) {
    // (reductions f coll)
    return new LazySeq(function () {
      return s ? _reductions(f, first(s), rest(s)) : list(f());
    });
  } else {
    // (reductions f val coll)
    return reduced_QMARK_(init)
      ? list(init.value)
      : cons(init, new LazySeq(function () {
                     if (s) {
                       return _reductions(f, f(init, first(s)), rest(s));
                     }
                   })
        );
  }
}
Now more tests. Expecting to not find one that fails. 😃

borkdude21:12:57

I actually found the previous version more readable

pez21:12:23

Interesting. I’ll revert. 😃

borkdude21:12:48

and it would also be easier to debug by inserting some console.log in between stuff, vs when you have just one return + expr

pez21:12:23

No doto? 😃

borkdude21:12:35

no doto in js ;)

pez21:12:48

Is there a better way to express this?

(is (= "[object Object]" (str (jsv! '(reductions + '()))))
    "Returns LazySeq")

borkdude21:12:37

yes, call vec within jsv!

borkdude21:12:50

and then compare with an empty vec

borkdude21:12:13

you can write: (eq (reductions + '()) (jsv! '(vec (reductions + '()))

borkdude21:12:25

or do you want to test that it is properly lazy?

borkdude21:12:41

if so then I would not test the type but if it behaves truly lazy

pez21:12:11

Yes. But I also like the comparison to clojure reduction.

borkdude21:12:39

you can try this:

(vec (take 10 (reductions + (range))))

pez21:12:13

Thanks! I’m happy I assigned myself to this!

borkdude21:12:35

thanks for contributing 🎉

pez21:12:26

Does it make sense to make almost all tests in the style (eq (reductions + '()) (jsv! '(vec (reductions + '())) ?

borkdude21:12:54

also call vec on the lhs

borkdude21:12:55

just identical expressions

pez21:12:19

No eval in ClojureScript 😃

borkdude21:12:17

this can be solved using a macro:

(defmacro eq-expr [expr]
 `(eq expr (jsv! (list 'quote expr)))

borkdude21:12:24

but I was too lazy to write that

1
pez22:12:08

A bit unlucky with the macro here:

FAIL in (reductions-test) (squint/compiler_test.cljs:953:9)
no val
expected: (eq-expr (vec (reductions + (quote ()))))
  actual: #object[TypeError TypeError: Cannot read properties of undefined (reading 'cljs$core$IFn$_invoke$arity$1')]

borkdude22:12:58

let's not get into another rabbit hole and save the macro for later

borkdude22:12:04

I'm not even sure if I want the macro

pez22:12:39

Looks like it could do wonders with the compiler tests. 😃 But I am not keen on diving into another rabbit hole. Not explored the current one yet.

Steve Huffman20:12:33

Hi all. Newie question. Why doesn’t something like this work? I presume bc of the macro?

(squint/compile-string "(for [i (range 10)] (println i))")
; Execution error (ArityException) at squint.compiler/eval8630$fn (compiler.cljc:168).
; Wrong number of args (0) passed to: squint.compiler/transpile-form/fn--8703

1
borkdude21:12:04

@U068RUGD875 In which environment is this?

borkdude21:12:10

should normally work

borkdude21:12:42

ah I see, from clojure, I'll fix that

borkdude21:12:46

let me know if you run into more bugs

Steve Huffman21:12:19

Will do, thanks. I was surprised that was a bug. just thought I wasn’t using it right.

borkdude21:12:18

CLJS is more lenient in functions with fixed arguments which is where the bug came from

Steve Huffman21:12:04

What I was playing around with is compiling and serving the squint code from a clojure process that’s acting as a web app backend.

borkdude21:12:01

yep, that's a good use case. it's documented in the README as well

Steve Huffman21:12:42

ok, another newbie question. I have a file (client_macros.cljc) with a simple macro in it and

(ns client-macros)

(defmacro add [x y]
  `(+ ,x, ,y))
and another file client_js.cljs that calls it
(ns client-js
  (:require-macros [client.macros :refer [add]]))

(println (add 1 2))
when I compile with compile-string*, the call to add isn’t expanded. I also made a squint.edn per the readme
{:paths ["src-squint"]}
Am I supposed to do something else?

borkdude21:12:02

hmm, this isn't yet supported in the JVM side of things, only in the node side of things and when you work via the CLI: npx squint compile but there is a way to configure macros another way, let me look that up

borkdude21:12:24

user=> (s/compile-string "(foo.bar/baz 1)" {:macros {'foo.bar {'baz (fn [&form &env x] (inc x))}}})
"import * as squint_core from 'squint-cljs/core.js';\n2;\n"

Steve Huffman21:12:47

thank you, I’ll give this a try

borkdude21:12:06

if you have a JVM macro, you can do this:

(s/compile-string "(foo.bar/baz 1)" {:macros {'foo.bar {'baz #'jvm-namespace/the-macro}}})

borkdude21:12:46

user=> (defmacro inc! [x] (inc x))
#'user/inc!
user=> (s/compile-string "(foo.bar/baz 1)" {:macros {'foo.bar {'baz #'inc!}}})
"import * as squint_core from 'squint-cljs/core.js';\n2;\n"

Steve Huffman23:12:41

works. pretty cool. thank you!

👍 1