PDA

View Full Version : A nice (verbal) example of recursion



RobbeK
24-03-2014, 23:46
"If you do not know what recursion is, read this sentence - till you understand it"


------------------

ReneMiner
24-03-2014, 23:52
:good:

(10 chars)

peter
25-03-2014, 02:05
"If you do not know what recursion is, read this sentence - till you understand it"

Oh, Recursion:



Uses "ui"
#INCLUDE "abc.inc"

OpenWindow 640, 480
SetHandleDC hdc, hwnd

Sub Main(x, radius, lev As Long)
Single col = 126 * lev/4
DrawEllipse x-40, 240, radius*.6, radius*.8, 0, col
If lev >1 Then
lev -=1
Main x - radius/2, radius/2, lev
Main x + radius/2, radius/2, lev
EndIf
End Sub

Canvas_Clear &hFF0000
Main 320,-240, 8
Main 320, 240, 8
Canvas_Redraw

While IsWindow(hwnd) And Key(27)=0
Sleep 10
Wend
Canvas_Window End hwnd