From: "Brian Schröder" Date: 2005-08-13T00:15:22+09:00 Subject: Re: cartesian product - next to last version On 12/08/05, Dave Burt wrote: > Interesting benchmarks. Thanks for sharing these and your code, Brian. > > I was initially surprised that your recursive code was quicker than my > procedural, but when you look at them, it's obvious that my code is just > doing more, unnecessarily, while yours is nice and simple. > > Any tips on learning to write code like your 3-line functonal recursive > cartprod? > > Cheers, > Dave > Thanks Dave, regarding the tips you requested. The only thing that helps is to think about how to split the problem recursively. It is like an inductive proof. So it helps to make lots of inductive proofs throughout your studies and get into a mindset for this. Then the solution comes naturally. All a matter of experience I suppose (Though I don't have that much, there are lots of more experienced people here.) Sorry if that is not of much help, maybe thinking about the proposed solutions in this thread and the other threads will be more of a help. best regards, Brian -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/