iterate

EveAndersson.com : API Browser : iterate

iterate

iterate n f x
Defined in tcl/ad-functional.tcl

Returns {x (f x) (f (f x) (f (f (f x))) ...}.

Examples

  • iterate 10 [lambda {x} {expr $x+1}] 5 = {5 6 7 8 9 10 11 12 13 14}
  • iterate 10 [lambda {x} {expr $x*2}] 1 = {1 2 4 8 16 32 64 128 256 512}
  • iterate 4 tail {1 2 3 4 5} = {1 2 3 4 5} {2 3 4 5} {3 4 5} {4 5}

Parameters:
n
f
x
[ show source ]

Show another procedure:

eve@eveandersson.com