English 中文(简体)
Logo - Recursive Procedures
  • 时间:2024-12-22

Logo - Recursive Procedures


Previous Page Next Page  

In a recursive procedure, there will be a recurrence call of the procedure within the procedure. Let us consider the following code −

to spiral_recur :n
   if :n < 1 [stop]
   fd :n
   rt 20
   spiral_recur 0.95 * :n
end

The procedure spiral_recur has been called from the procedure body itself. The following screenshot shows the execution and output of the code.

Recursive Procedures Advertisements