[[English Page]]~
[[Elementary Techniques]] | [[Techniques of Function]] | Techniques of Recursion | [[Techniques of Number]]

#contents

*Replace in a recursive function [#eb7b48e9]
**Sample Code 1 [#e3a7c461]
 a(X):XXXXrXXXXla(srslX)
 a(r)
 (20B)
 
The code above can be compressed by replacing XXXX by another variable.
 a(X,Y):YrYla(srslX,XXXX)
 a(r,)
 (19B)

**Examples [#o5494688]
-[[Problem 0441]]

*Special first term [#m9d39ab4]
**Sample Code 1 [#e3a7c461]
 a(X,Y):YrYla(srslX,XXXX)
 a(r,sss)

Even if you replace something by Y, the rule of Y isn't applied for "1st Y". ~
Thus, you can use "1st Y" freely.

**Sample Code 2 [#v5560bd3]
 a(X,Y):XYXa(XX,l)
 a(srsl,r)

**Sample Code 3 [#p1575461]
 a(X,Y):XXXXYa(sX,YYl)
 a(r,)
In this code, "1st Y" and "2nd Y" is special.

**Examples [#x97b838b]
-[[Problem 0651]]

*Controll the spped of growth [#xe4dbfff]
**Sample Code 1 [#ab7d95e0]
a(X,Y):XXXXra(sY,X)
a(r,r)

X grows with a spped of 1/2.

**Sample Code 2 [#n4d973bf]
a(X,Y,Z):Xra(ssY,sZ,X)
a(,,)

This code gives a sequence [0,2,3][3,5,6][6,8,9][9,11,12]...

**Sample Code 3 [#w85e28fe]
 a(X,Y,Z):Xra(sYX,Z,Y)
 a(,,s)

This code gives a sequence [0,1][3,4][6,7]...~
"s" and "" appar at Y alternatively.

**Examples [#ld1a4eec]
-[[Problem 0544]]
-[[Problem 0547]]

**Sample Code 2 [#pd3c6df3]
育たない再帰とかで
**Examples [#c51fb1eb]
-[[Problem 0090]]
-[[Problem 1687]]

*Change of variables [#d5ec0183]
**Sample Code [#o3fadcb7]
 a(X):XrXrXrXra(XrXlX)
 a(s)

Put Y = Xr, then this code can be transformed to the following code:

 b(Y):YYYYb(newY = [newX]r = XrXlXr = YYllY)
 b(sr)

 b(Y):YYYYb(YYllY)
 b(sr)

**Examples [#h19a3f89]
-[[Problem 1309]]
-[[Problem 1720]]

*Multiple recursion [#z2d43815]
**Sample Code 1 [#i62107f5]
 f(X):ssXlssf(sX)
 f()
 (12B)
This code can be compressed by recycling "ss":
 f(X):ssXlf(f(sX))
 f()
 (11B)

**Examples [#s1d10173]
-[[Problem 1687]]
-[[Problem 0090]]
-[[Problem 0710]]

*Recursion with many functions [#je2c6d23]
 f(X):[1]
 a(X):[2]a(f(X))
 a(f([3]))

This code can be compressed by using two recursive functions. 

 f(X):a([1])
 a(X):[2]f(X)
 f([3])


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS