Fork me on GitHub
#exercism
<
2020-04-02
>
pez15:04:20

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

hindol15:04:56

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

pez16:04:41

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

😅 4
pez18:04:11

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

💯 4
jaihindhreddy19:04:13

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 😅

pez19:04:11

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.

pez19:04:16

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...

pez19:04:43

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

jaihindhreddy20:04:43

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 😄

pez20:04:44

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

✔️ 4
hindol20:04:47

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

💯 4
hindol20:04:55

It states your intent clearly.

jaihindhreddy20:04:31

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)

pez21:04:52

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.

hindol21:04:59

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

hindol21:04:33

But not sure the whole community agrees or not.

4
pez21:04:54

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

hindol21:04:39

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

jaihindhreddy21:04:00

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.

pez21:04:31

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.

👍 4
hindol21:04:00

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

pez21:04:42

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

jaihindhreddy21:04:04

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

pez21:04:16

That would be awesome!

hindol05:04:31

Yeah, cannot see the conversation actually. Capturing the URL before publishing the solution might have worked.

pez06:04:59

I'll wait with publishing until you've checked.

hindol06:04:20

Na, still can't see. What I remember is I opened a solution that I wanted to mentor, left it as it is, and some other mentor commented. I was able to see those comments but not the name of the mentor. May just be a glitch in the system.

pez06:04:05

Maybe @U883WCP5Z has some link that works?

pez06:04:47

There are some traces on the web for something like this having existed: https://twitter.com/exercism_io/status/693466068195495936

pez07:04:22

Submitted Hamming, FYI. 😃

👍 4
hindol07:04:08

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

hindol08:04:18

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.

hindol08:04:46

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

pez08:04:51

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

pez19:04:29

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

dharrigan20:04:53

Is it possible to request a different mentor?

hindol20:04:55

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

hindol20:04:17

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

4