Previous Page Next Page Contents

fp::nestvals -- repeated composition returning intermediate values

Introduction

fp::nestvals(f,n) returns a function which applies the function f n-fold repeatedly to ist argument and returns the intermediate results.

Call(s)

fp::nestvals(f, n)

Parameters

f - function
n - nonnegative integer

Returns

A function.

Related Functions

_fconcat, _fnest

Details

Example 1

Apply f 3 times nested to x:

>> fp::nestvals(f, 3)(x)
                      [x, f(x), f(f(x)), f(f(f(x)))]

Example 2

Apply cos 4 times nested to 1.0 and return the result and intermediate values:

>> fp::nestvals(cos, 4)(1.0)
       [1.0, 0.5403023059, 0.8575532159, 0.6542897905, 0.7934803588]

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000