On Sun, Jan 15, 2017 at 05:05 Peter Jakobsson <[email protected]> wrote:
Hey Peter, hopefully you've seen my other post. I obviously hadn't read the docs because Find in sorted array does everything that I could hope for, and does it quite nicely. It's set up for find and insert operations and works great. A very nice addition to the language. > > (Although, once it does, the binary search makes a massive difference, > especially in recursive logic where the number of array lookups increases > exponentially with the size of the array). > There's no need to use recursion. Dave Terry's code avoids it with iteration but you can always replace recursion with a stack. Recursion automatically gives you a stack for "free"...but of the cost of stacking a full method instance+variable frame instead of just stacking the values in a stack that you manage. Also, if you care, check the Wikipedia (or wherever you like), and you'll see that neither approach involves an exponential increase. If it matters to youl ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

