Fork me on GitHub
#announcements
<
2021-12-27
>
lilactown19:12:03

What is a hike, but a really long walk? ⛰️🚶:skin-tone-2: I am pleased to announce a new library, https://github.com/lilactown/cascade. 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 https://cljdoc.org/d/town.lilac/cascade/1.1.0/doc/readme. Any questions, comments, or issues can be DMed to me or opened in a GitHub issue. Happy hiking!

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

When you refactor so hard you make a library?

😎 2
lilactown19:12:43

😂 exactly that

lilactown19:12:11

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:

lilactown20:12:47

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

1
Jakub Holý (HolyJak)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? 🙏

Ivan09:01:54

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

1
lilactown17:01:51

@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
lilactown17:01:33

like Ben said, I wanted this ability in pyramid to normalize extremely large data structures. See it used here: https://github.com/lilactown/pyramid/blob/trampoline/src/pyramid/core.cljc#L120-L133

lilactown17:01:12

a library that meets a similar need is clojure.zip. 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

lilactown17:01:38

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