[#2367] Standard libraries — Dave Thomas <dave@...>

From ruby-dev summary:

60 messages 2004/02/11

[#2397] PATCH: deprecate cgi-lib, getopts, importenv, parsearg from standard library — Gavin Sinclair <gsinclair@...>

Index: cgi-lib.rb

15 messages 2004/02/12

[#2465] PATCH: OpenStruct#initialize to yield self — Gavin Sinclair <gsinclair@...>

This is a common approach I use to object initialization; I don't know

24 messages 2004/02/19

Re: foldl and foldr

From: Mathieu Bouchard <matju@...>
Date: 2004-02-25 14:55:54 UTC
List: ruby-core #2507
On Wed, 25 Feb 2004, Sean E. Russell wrote:

> For those not familiar to these methods, they're from the functional 
> programming space, and they allow you to combine array contents.  They're 
> generalizations of the "join()" function.
> 
> Example: the sum of all numbers between 1 and 100:
> Current: 
> 	sum = 0
> 	(1..100).to_a.each {|x| sum += x}
> 	puts sum
> New:
> 	puts ((1..100).to_a.foldl(0) {|a,b| a+b})

Hi, please have a look at Enumerable#inject. BTW I'm sorry to have pushed
for that naming back in 2000, as I later changed my mind.

(Then I created a library in which the same thing is called, well, "fold")

________________________________________________________________
Mathieu Bouchard                       http://artengine.ca/matju


In This Thread