in reply to Re^2: Syntactic sugar for tail call optimizations
in thread Syntactic sugar for tail call optimizations

And of course you can easily provide an example proving your polemic assertion...

Of course:

use enum qw[ CODE GRAPH START PATH SEEN ]; sub _pathsFrom { return $_[CODE]->( @{ $_[PATH] }, $_[START] ) unless exists $_[GRAPH]->{ $_[START] }; for ( @{ $_[GRAPH]->{ $_[START] } } ) { if( exists $_[SEEN]->{ $_[START] . "-$_" } ) { return $_[CODE]->( @{ $_[PATH] }, $_[START] ); } else { _pathsFrom( @_[ CODE, GRAPH ], $_, [ @{ $_[PATH] }, $_[START] ], { %{ $_[SEEN] }, $_[START] . "-$_", undef } ); } } } sub pathsFrom(&@) { _pathsFrom( @_, [], {} ) }

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Syntactic sugar for tail call optimizations
by LanX (Saint) on May 27, 2011 at 16:05 UTC
    Ah I see a trivial example already remotely requiring recursion

    without sample data for your spontaneous example I can't test, but the following should do.

    use enum qw[ CODE GRAPH START PATH SEEN ]; sub _pathsFrom { _PATHSFROM: { return $_[CODE]->( @{ $_[PATH] }, $_[START] ) unless exists $_[GRAPH]->{ $_[START] }; for ( @{ $_[GRAPH]->{ $_[START] } } ) { if ( exists $_[SEEN]->{ $_[START] . "-$_" } ) { return $_[CODE]->( @{ $_[PATH] }, $_[START] ); } else { @_=( @_[ CODE, GRAPH ], $_, [ @{ $_[PATH] }, $_[START] ], { %{ $_[SEEN] }, $_[START] . "-$_", undef } ); redo _PATHSFROM; } } } }

    If not, enlighten us!

    UPDATE(18:16 CEST): This thread is about implementating tail call recursions, thanks for trolling with a graph-search recursion which isn't tail code.

    Cheers Rolf

      This thread is about implementating tail call recursions, thanks for trolling with a graph-search recursion which isn't tail code.

      Oh, sorry. I thought you'd know that every recursive algorithm can be made into a tail-recursive one(*).

      So you see there is no trolling and no polemic; just an example, as you requested, that you don't know how to handle.

      And, BTW, one disproves your flimsily expounded theory.

      * All you need to do is implement the CPS transform.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I thought you'd know that every recursive algorithm can be made into a tail-recursive one

        Well - believe it or not - I knew. But your undocumented cut&paste doesn't worth it.

        This thread is about syntactic alternatives to goto &sub for implementing tail-call patterns and not about your inquisitional tactics to sabotage threads you consider heretical.

        So I better resort in not feeding the BUK!

        And now you have the last word ... :)

        Cheers Rolf