Fork me on GitHub

What is a hike, but a really long walk? ⛰️🚶:skin-tone-2: I am pleased to announce a new library, It provides a couple of helpful capabilities in two namespaces 1. cascade.core is a collection of continuation-passing, thunk-producing versions of many Clojure core functions. This provides the ability to write recursive algorithms that do not use the call stack in Clojure(Script) by combining familiar operations like reduce and into with trampoline. 2. cascade.hike is like `clojure.walk`, but defines `walk` in a way that supports walking very large, nested data structures without using the call stack. prewalk, postwalk et al. work just like their original counterparts but can traverse arbitrarily nested forms without overflowing the stack. Documentation is Any questions, comments, or issues can be DMed to me or opened in a GitHub issue. Happy hiking!

🎉 19
👏 18
🆒 6
🥾 1
lightsaber 1
Ben Sless19:12:05

When you refactor so hard you make a library?

😎 2

😂 exactly that


had an itch I needed scratched and thought maybe other people would too!

Ben Sless19:12:01

Nicely done I'm of a mind to extract the lazy streams idea from micro kanren and see how it interacts with this :thinking_face:


sounds neat. not familiar with that

Ben Sless20:12:33

It's about interleaving execution or backtracking fairly. Very interesting

Ben Sless04:12:36

Another thing which I find interesting is how CPS identity is 1 in Church numerals and constantly is 0

Jakub Holý09:01:08

Hi! It would help me to understand when I might want to use Cascade if the README has some motivating examples. I do no think I run into the need that it satisifies. What kind of algorithms/problems that need you have you two encountered? 🙏


from what I understand, it emulates recursion but it doesn't fill up the stack. ie, a classic problem is depth-first search on a tree (think of reimplementing ls -R for a filesystem) - the recursive solution is simple but in practice limited by the stack size, so if the depth exceeds some limit it crashes. With cascade you keep the simple nature of the solution but the limit is "magically" gone.

🙏 1
Ben Sless11:01:05

Specifically, Will came to this solution trying to prevent stack overflows in his other library, pyramid


@U0522TWDA the cascade.walk namespace is what originally motivated me to write the rest of the library. it allows you to walk an arbitrarily nested Clojure data structure without worrying about failing with a StackOverflow exception

🙏 1

like Ben said, I wanted this ability in pyramid to normalize extremely large data structures. See it used here:


a library that meets a similar need is cascade is quite a bit faster than zippers IME, although I haven't figured out how to move up/down/left/right in all the ways zippers do yet


there's some other interesting properties that Ben referenced above, like the ability to pause/resume and interleave the calculation of algorithms that are written in the trampolined styled that cascade is

Jakub Holý21:01:05

Thanks a lot!