, , , . , , x val, val+1,...
x k j x == val? x == val+1? element
--------------------------------------------------------- -------
val val*fac fac*k = val*val*fac True False val (x)
val+1 val*fac fac*k = val*val*fac False True val*fac (k)
val+2 val*fac fac*k = " False False val*val*fac (j)
val+3 val*fac fac*k = " False False val*val*fac (j)
...
, , k j , val fac.
Haskell. :
[ 1, fac, fac*fac, fac*fac*fac, ...]
map (val*).
, :
1) (*fac). , :
f x = fac*x
:
[ 1, f 1, f (f 1), f (f (f 1)), ... ]
, iterate .
2) Note that the tail is a sequence of powers of a sequence of map (*fac)sequences. Therefore, you can write:
powers x = 1 : map (*x) (powers x)
This is essentially the same as (1), but sometimes it is easier to determine the relationship between the sequence and the tail.
source
share