From: Steven Hansen Date: 2006-09-05T12:39:46+09:00 Subject: Re: Binary Search Using Lambda On Sep 4, 2006, at 8:09 PM, Logan Capaldo wrote: > > On Sep 4, 2006, at 10:59 PM, Steven Hansen wrote: > >> >> Greetings, >> >> I've been playing around with various ways to write a function >> that does a binary search on an array of integers. >> Below is one of my implementations. I'm wondering if it is >> possible to avoid passing the function to itself >> in order to achieve the recursive call. >> > > You don't need one. > > % cat recursion_diversion.rb > func = lambda do |x| > if x == 0 > puts "Recursing" > func.call(1) > else > puts "Done" > end > end > > func.call( 0 ) > > % ruby recursion_diversion.rb > Recursing > Done > > > Cool, thanks Logan.