On Thu, 2002-09-12 at 06:46, Piers Cawley wrote: > Here's the classic example of mutual recursion: > > sub even ($n) { > given $n { > when 0 { return 1 }; > default { odd($n-1) }; > } > } > > sub odd ($n) { > given $n { > when 0 { return } > default { even($n-1) }; > } > } > > even(2); > > Which throws C<< [prefix::val (not implemented) even] Prefix operator odd > >> while compiling the tree. Curse! >
That's because the compiler does not currently handle the case of calling a function before it's defined. Use: sub odd($n); first to declare the function. This gets you a warning about redefining odd, but that's ignorable. -- Aaron Sherman <[EMAIL PROTECTED]> http://www.ajs.com/~ajs