exercism

The Clojure Track: https://exercism.io/my/tracks/clojure
pez 2020-04-02T15:17:20.117500Z

I submitted Collatz Conjecture for mentor review. Sort of boring solution, but maybe that's whats called for...

hindol 2020-04-02T15:28:56.118400Z

Wow, mentoring queue is consumed like a hot-cake. I was like a minute late. Someone already took over the mentoring I believe, 😅

pez 2020-04-03T07:33:22.136600Z

Submitted Hamming, FYI. 😃

👍 1
hindol 2020-04-03T07:52:08.137800Z

So, although someone else mentored, I can see the comments by going to this link: https://exercism.io/mentor/solutions/15f6c72d1d824b23b348111b0ae7971a

hindol 2020-04-03T08:01:18.138300Z

I want to call out this difference a little,

(map = coll1 coll2)
Here map will internally call (= 0th-of-coll1 0th-of-coll2) and so on.
(map = [[a b] [c d]]) ;; => Arity exception
To make this work, you need #(apply = %) as the mapping function. More fun! #(apply mapv vector %) can transpose a matrix.

hindol 2020-04-03T08:09:46.138700Z

Also, it might be fun to re-write the above exercise using some-> or some->>.

pez 2020-04-03T08:22:51.138900Z

Regarding inline tests, it seems to be controversial: https://clojureverse.org/t/inline-tests-do-you-do-it/4083 😃

pez 2020-04-02T16:06:41.118700Z

@jaihindhreddy beat you to it. And he agreed my solution was too boring. 😃

😅 1
pez 2020-04-02T18:45:11.119200Z

Amazing how much there is to learn from seemingly simple tasks.

💯 1
jaihindhreddy 2020-04-02T19:08:13.119400Z

Absolutely. Never before did I have a kind of zen feeling when learning a programming language. Haskell felt like a complete nightmare compared to this. I've nothing against it. It's just that I try to learn every year, but it never quite clicks 😅

pez 2020-04-02T19:36:29.121200Z

Submitted Series. Thinking that while the mentoring queue is what it is right now, I might as well. 😃

pez 2020-04-02T19:39:11.121300Z

I experienced something like it when I coded in PostScript, but back then there was no www, only me and the books I found. This mentoring layer atop is something else.

pez 2020-04-02T19:46:16.121500Z

In the `iterate`ing fn, the `even?` ensures that `/` returns an int, but if I don't see the `even?` on a first glance, ratios will be in the back of my mind. `quot` wouldn't depend on that context. Not quite following here...

pez 2020-04-02T19:53:43.121800Z

OK. I sort of understand it a bit now. But what is the problem with ratios there?

jaihindhreddy 2020-04-02T20:02:43.122Z

No problem with ratios. The fact that we're dealing all in integers is made clearer by quot than /. The combination of even? and / makes it equally clear but when I can achieve the same constraints more locally, I prefer that. This piece of code is too trivial for this effect to be prominent. But in larger pieces of code, I sometimes found that when I pulled out a piece of code that relied on constraints maintained by it's context, and tried to re-use it somewhere else, I realise that context, almost always as a bug I'd have to fix later. I'm failing to articulate this clearly too. I've noted this down, and if-n-when I find a precise way to say this, I'll ping you 😄

dharrigan 2020-04-02T20:10:53.122400Z

Is it possible to request a different mentor?

pez 2020-04-02T20:18:44.125200Z

So, it is that there will never be a ratio produced that you think is made clearer by quot than by /?

✔️ 1
hindol 2020-04-02T20:28:55.126200Z

No. But you can rate a mentor in the end.

hindol 2020-04-02T20:29:47.126300Z

quot means you are willing to sacrifice the remainder part. It is indeed clearer when you want to guarantee the result is an integer.

💯 1
hindol 2020-04-02T20:29:55.126500Z

It states your intent clearly.

hindol 2020-04-02T20:40:17.127500Z

But mentors can pick, so you can give a heads up here or to the person directly.

➕ 1
jaihindhreddy 2020-04-02T20:54:31.127900Z

Exactly what hindol said. Edit: In other words, quot is exactly what you want, and / happens to behave the same way in the context you're in, and also has the additional benefit of slightly better performance. (Take the last part with a spoon of salt. Haven't benched 'em)

pez 2020-04-02T21:09:52.128400Z

I'm not sure I agree. I am not willing to sacrifice any remainder part. I am sure there won't be any remainder part, which is something different, for me.

hindol 2020-04-02T21:11:59.128600Z

I mean, quot states your confidence that there won't be any remainder in that case.

hindol 2020-04-02T21:12:33.128800Z

But not sure the whole community agrees or not.

➕ 1
pez 2020-04-02T21:22:54.129100Z

Or quot makes sure there is no remainder, while / states my confidence that there won't be any. 😃

hindol 2020-04-02T21:26:39.129300Z

/ is probably doing more work than necessary. But unless you're doing performance critical stuff, don't see a problem with either.

jaihindhreddy 2020-04-02T21:31:00.129500Z

I agree with / stating the confidence that there won't be any ratios there, but in the eyes of a reader unfamiliar with the code, they're building up their mental model and constraints on values based on the fns they're seeing. And quot allows them to know that the output will be an int faster than / here because they'd also have to read the even? to understand that. That's what I meant by locality of reasoning. And because it's so minor, and the context is right beside the /, I said it's my pet-peeve and not even a nitpick. We're deep in personal preference land TBH. Edit: I do appreciate well considered discussion on things that seem like trivialities. I for one definitely becomes a better programmer through these things. Thanks for that.

pez 2020-04-02T21:37:31.129800Z

I just told you in a comment, but I'll say it here as well. Please keep up the pedantic level. I want to know about those pet peeves, and get aware of those details. If it was some regular code review situation, maybe I would be more pragmatic about things, but the whole point with a mentored approach is, for me, to learn about all the things.

👍 1
hindol 2020-04-02T21:40:00.130Z

Now I am curious what other discussions happened. Can you maybe link to the mentored solution (not the published solution)?

pez 2020-04-02T21:50:42.130300Z

You'd have to find all solutions @jaihindhreddy has given me feedback on. 😃 But here is the link to this latest one, anyway: https://exercism.io/my/solutions/9174d6f84ea24b668c2cf0a9b5ef1715

pez 2020-04-02T21:52:31.130700Z

And this one: https://exercism.io/my/solutions/17888633049d4dbe96dc0b9c690ec73c

jaihindhreddy 2020-04-02T21:53:04.131100Z

Unfortunately, I don't think the mentor-mentee interaction can conveniently be made public through Exercism itself.

pez 2020-04-02T21:54:16.131300Z

That would be awesome!