4 ms·
Non-idiomatic ClojureScript, 10 lines: https://gist.github.com/raspasov/0521706c3f963a9209152bfb2becd91c https://gist.github.com/raspasov/0521706c3f963a9209152
by raspasov 6y ago
Non-idiomatic ClojureScript, 10 lines:
https://gist.github.com/raspasov/0521706c3f963a9209152bfb2becd91c https://gist.github.com/raspasov/0521706c3f963a9209152bfb2be...
IMO The problem is poorly defined. Data structures should avoid control flow instructions like "reset_lesson_position"
- js8 6y agoWhat if we rephrased it as having the lists sorted by additional field "category", and you are supposed to reset the counter in a new category?
- josevalim 6y agoCorrect. In the real-life example this came from, a separate parameter would control how to reset the lesson counter but it was moved into a boolean property to keep the problem focused. Your "category" idea would be a nice addition to the problem though. The logic of when to reset would still be fairly simple and folks would have to explore how to represent the initial category value before traversal starts. I assume most would solve it with nil and maybe/option types.