<div dir="ltr"><div class="gmail_default" style="font-family:monospace">Hello <a class="gmail_plusreply" id="plusReplyChip-1" href="mailto:core-libs-dev@openjdk.org" tabindex="-1">@core-libs-dev</a>,</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">When working with streams, I often run into situations where I have to "demote" back to imperative code because I am trying to solve a problem best solved by recursion.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Consider the common use case of cycling through permutations to find all permutations that satisfy some condition. With recursion, the answer is incredibly simple -- just grab an element from the set, then call the recursive method with a copy of the set minus the grabbed element. Once you reach the empty set, you've reached your terminal condition.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Use cases like that are not only incredibly common, but usually,  embarrassingly parallel. The example above of cycling through permutations is only a few lines of imperative code, but I struggle to imagine how I would do this with Streams.</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">I guess let me start by asking -- are there any good ways currently to accomplish the above permutation example with Streams? And if not, should there be?</div><div class="gmail_default" style="font-family:monospace"><br></div><div class="gmail_default" style="font-family:monospace">Thank you for your time and consideration.</div><div class="gmail_default" style="font-family:monospace">David Alayachew</div></div>