This approach makes "nested" recursion possible: https://github.com/fbsolo/ProjectEuler/blob/master/main.go
- Frank On Friday, April 25, 2014 at 7:24:28 AM UTC-7, emepyc wrote: > > Yes, but you should return the result ;-) > > http://play.golang.org/p/h-VYDrY7Ov > > M; > > On 25/04/14 14:41, Francesc Campoy Flores wrote: > > And just because you should always use early return: > > > > http://play.golang.org/p/cbiM9icWr8 > > > > > > On Fri, Apr 25, 2014 at 7:40 AM, Francesc Campoy Flores > > <cam...@golang.org <javascript:> <mailto:cam...@golang.org <javascript:>>> > wrote: > > > > You could also pass the function to itself and define a recursive > > function type: > > > > http://play.golang.org/p/bYn0yGE-sL > > > > More for fun that for production though, this is not the most > > readable code ever. > > > > > > On Fri, Apr 25, 2014 at 6:04 AM, <anid...@gmail.com <javascript:> > > <mailto:anid...@gmail.com <javascript:>>> wrote: > > > > I have a similar solution for a simple Fibonacci generator: > > > > func main() { > > var fibonacci func(int) int > > fibonacci = func (n int) int { > > if n == 0 { > > return 0 > > } else if n == 1 { > > return 1 > > } else { > > return fibonacci(n - 1) + fibonacci(n - 2) > > } > > } > > fmt.Println("Fibonacci (30) =>", fibonacci(30)) > > } > > > > This seems to be the most simple way to do a anonymous recursive > > function in Go. > > > > Regards, > > > > Anindya Chatterjee > > > > On Monday, November 16, 2009 4:18:43 PM UTC+5:30, Helmar wrote: > > > > It's not nice to always write something like: > > > > var q func(p [][]byte); > > q = func(p [][]byte) { > > ... > > q(...); > > ... > > }; > > > > Is there a better way? > > > > Regards, > > -Helmar > > > > -- > > You received this message because you are subscribed to the > > Google Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from > > it, send an email to golang-nuts...@googlegroups.com > <javascript:> > > <mailto:golang-nuts+unsubscr...@googlegroups.com <javascript:>>. > > > For more options, visit https://groups.google.com/d/optout. > > > > > > > > > > -- > > -- > > Francesc Campoy > > http://twitter.com/francesc <http://twitter.com/francesc> > > > > > > > > > > -- > > -- > > Francesc Campoy > > http://twitter.com/francesc <http://twitter.com/francesc> > > > > -- > > You received this message because you are subscribed to the Google > > Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > > an email to golang-nuts...@googlegroups.com <javascript:> > > <mailto:golang-nuts+unsubscr...@googlegroups.com <javascript:>>. > > For more options, visit https://groups.google.com/d/optout. > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.