Category talk:Iteration: Difference between revisions

From Rosetta Code
Content added Content deleted
mNo edit summary
m (remove last sententce, as not sure if it is true (I don't really understood what a callback is))
Line 2: Line 2:


: Loop/Map is already there, as [[Apply a callback to an Array]] (see the Common Lisp solution!) I don't know what Loop/Fold means, but maybe it's also already there under another name. --[[User:Ce|Ce]] 13:28, 18 April 2008 (MDT)
: Loop/Map is already there, as [[Apply a callback to an Array]] (see the Common Lisp solution!) I don't know what Loop/Fold means, but maybe it's also already there under another name. --[[User:Ce|Ce]] 13:28, 18 April 2008 (MDT)
::The articles [[Sum and product of array]] contains some examples of '''Fold'''(or reduce). '''Fold''' apply a binary function(ZxZ->Z) to each elements of a collection with an accumulator, the result value is set to the accumulator, and the final value of accumulator after iterated all elements is the result of '''Fold''' (the accumulator initialized to 1.0 in Product case, and 0.0 in Sum case). '''Map''' is similar, but with an unary function Z->Z. There is also '''Filter/Select'''(compare [[Select from Array]]) similar to '''Map''', with an unary boolean function, but don't keep elements if result value is false. Pedantically, these ''Functionals'' are examples of ''apply a callback to an array'' in imperative sense -- [[User:Badmadevil|badmadevil]] 05:58, 19 April 2008 (MDT)
::The articles [[Sum and product of array]] contains some examples of '''Fold'''(or reduce). '''Fold''' apply a binary function(ZxZ->Z) to each elements of a collection with an accumulator, the result value is set to the accumulator, and the final value of accumulator after iterated all elements is the result of '''Fold''' (the accumulator initialized to 1.0 in Product case, and 0.0 in Sum case). '''Map''' is similar, but with an unary function Z->Z. There is also '''Filter/Select'''(compare [[Select from Array]]) similar to '''Map''', with an unary boolean function, but don't keep elements if result value is false. -- [[User:Badmadevil|badmadevil]] 05:58, 19 April 2008 (MDT)

Revision as of 12:04, 19 April 2008

I'm not sure about Loop/Map and Loop/Fold. I've never heard of them before. Can someone else fill in tasks for them? --Mwn3d 12:33, 14 April 2008 (MDT)

Loop/Map is already there, as Apply a callback to an Array (see the Common Lisp solution!) I don't know what Loop/Fold means, but maybe it's also already there under another name. --Ce 13:28, 18 April 2008 (MDT)
The articles Sum and product of array contains some examples of Fold(or reduce). Fold apply a binary function(ZxZ->Z) to each elements of a collection with an accumulator, the result value is set to the accumulator, and the final value of accumulator after iterated all elements is the result of Fold (the accumulator initialized to 1.0 in Product case, and 0.0 in Sum case). Map is similar, but with an unary function Z->Z. There is also Filter/Select(compare Select from Array) similar to Map, with an unary boolean function, but don't keep elements if result value is false. -- badmadevil 05:58, 19 April 2008 (MDT)