From 552c164a46051cdd78f86d8587c57f9a0c4668b9 Mon Sep 17 00:00:00 2001 From: Ryan Scheel Date: Sun, 8 Jul 2012 13:58:37 -0700 Subject: [PATCH] Parameter/Variable names for for_rev and map extended. --- doc/tutorial.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index ccb22c5b5cd..dec2ab29caa 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1971,18 +1971,18 @@ they apply to. Thus, Rust allows functions and datatypes to have type parameters. ~~~~ -fn for_rev(v: ~[T], act: fn(T)) { - let mut i = vec::len(v); +fn for_rev(vector: ~[T], action fn(T)) { + let mut i = vec::len(vector); while i > 0u { i -= 1u; - act(v[i]); + action(vector[i]); } } -fn map(v: ~[T], f: fn(T) -> U) -> ~[U] { - let mut acc = ~[]; - for v.each |elt| { vec::push(acc, f(elt)); } - ret acc; +fn map(vector: ~[T], function :fn(T) -> U) -> ~[U] { + let mut accumulator = ~[]; + for vector.each |elt| { vec::push(accumulator, function(elt)); } + ret accumulator; } ~~~~