in reply to understand and prevent 'Out of memory!' during sub recursion

You usually need to tell the function when it should stop recursing. In this case, you can do
&inter if grep @$_, @_

You can also use the tail recursion goto &inter here, as there's nothing happening after returning from the recursion.

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^2: understand and prevent 'Out of memory!' during sub recursion
by Discipulus (Canon) on Nov 09, 2017 at 10:39 UTC
    thanks choroba,

    but why &inter if $_[0][0] does not act the same of your, working, &inter if grep @$_, @_ ?

    Can you also expand a bit your last sentence?

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      $_[0][0] only checks the first array, i.e. it fails if the first array is not the longest one. grep, on the other hand, checks all the arrays.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,