From: Dave Burt Date: 2005-07-31T23:26:03+09:00 Subject: Re: Higher Order Functions >> Functional.every(proc{|x| x * 2}, [1, 2, 3]) > > IMO, you should pass a block. > > Then, you still can call it like that: > > Functional.every [1,2,3], &method(:foo) And better yet (IMO) is Ruby's own [1, 2, 3].collect &method(:foo) In the spirit of the thing, I'd prefer these functions to be first-class themselves. Perhaps the most obvious way to do this is: module Functional def every proc do |f, lst| lst.collect {|element| f[element] } end end end Which could be used like this: f = Functional.every g = proc {|x| x * 2 } p f[g, [1, 2, 3]] I'm not up with procs taking blocks; I think it can't be done. And if not, that's a barrier to using blocks in higher-order functions. You can pass them as parameters, of course, as in my example. This is Lispy, though - use square-brackets instead of "call" and you'll have more brackets than alphanums before you know it! Cheers, Dave