Logan Capaldo wrote:
>> > However, I'd probably write it like:
>> >   def nest(x, n = 2)
>> >     (1..n).inject(x) { |acc, _| yield(acc) }
>> >   end
>> 
>> I don't understand this one. I think "inject" is a fold and "yield"
>> returns a value and a continuation. Looks like the continuation is
>> ignored the next time it is accumulated, but won't the result have a
>> continuation in it?
> inject is a fold. yield is not a continuation, but rather a way of
> accessing the passed in function (block) anonymously.
> 
> def f
>   yield
> end
> 
> def f1(&b)
>   b.call
> end
> 
> f { puts "Does the same thing" }
> f1 { puts "Does the same thing" }

I see. So that was equivalent to:

  let rec nest ?(n=2) x f =
    Seq.fold (fun acc -> f acc) x {1 .. n}

but what is the meaning of the "_" in the Ruby "|acc, _|"?

-- 
Dr Jon D Harrop, Flying Frog Consultancy
The F#.NET Journal
http://www.ffconsultancy.com/products/fsharp_journal/?usenet