backlinks to this page:
Plugin Backlinks: Nothing was found.
Github:
A recursion s the process of repeating items in a self-similar way. In computer programming, a recursive function is a function that calls itself.
There are several classic recursive functions, like a function to calculate the factoral1) of a given number :
def factorial(n): if n == 1: return 1 else: return n * factorial(n-1)
To calculate the factorial of -per example- the integer 5 (written as 5!) you feed the integer 5 a an parameter to the factorial function above:
print factorial(5)
Recursions can also apper in graphics, like on this ad for Droste cacao (see Droste_effect): A wouman holding a packet of cacao with the image of a wouman holding a packet of cacao with the image of a woman holding a packet of cacao….
You can use python's turtle module to generate beautiful patterns like trees out of very few lines of code:
import turtle as t def y(length=100): """ paints a branch of a tree with 2 smaller branches, like an Y""" if length < 10: return # escape the function t.fd(length) # paint the thik branch of the tree t.left(30) # rotate left for smaller "fork" branch y(length * 0.6) # create a smaller branch with 2/3 the lenght of the parent branch t.right(60) # rotoate right for smaller "fork" branch y(length * 0.6) # create second smaller branch t.left(30) # rotate back to original heading t.fd(-length) # move back to original position return # leave the function, continue with calling program # calling the function the first time y(200) # create a tree, the first branch has a length of 200 pixel