Sub::Call::Recur - Self recursive tail call invocation.
sub fact { my ( $n, $accum ) = @_; $accum ||= 1; if ( $n == 0 ) { return $accum; } else { recur( $n - 1, $n * $accum ); } }
This module implements Clojure's recur special form.
recur
recur is a tail call to the current function. It is a bit like assigning the arguments to @_ and invoking a goto to the first expression of the subroutine.
@_
goto
It can be thought of as the redo operator, but for subroutines instead of loops.
redo
This form allows functional style looping with constant stack space.
Sub::Call::Tail
B::Hooks::OP::Check::EntersubForCV
http://github.com/nothingmuch/Sub-Call-Recur
Yuval Kogman
Copyright (c) 2009 Yuval Kogman. All rights reserved This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Sub::Call::Recur, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Call::Recur
CPAN shell
perl -MCPAN -e shell install Sub::Call::Recur
For more information on module installation, please visit the detailed CPAN module installation guide.