The fifth week of the Python class begins with the function. Recursive functions. Recursion cannot exceed 900 layers in Python, otherwise the error memory overflow or something. Also in R recursion too deep will be error, the threshold and Python is probably the same, 900 times the error.
Error message:
Error: Evaluation nesting too deep: infinite recursion/Options (expressions=)?
Error in rewinding: Evaluation nesting too deep: infinite recursion/Options (expressions=)?
Based on Python
# recursive function factorial def fact (n): if n==0: return 1 else: return N*fact (n-1) # recursive flip string def reverse (s): if s== ': C5/>return s else: return reverse (s[1:]) +s[0]
Python Run Results
Fact (Out[9]: 479001600reverse (' Hello World ') out[10]: ' Dlrow Olleh '
Based on R
# factorial fact <-function (n) { if (n==0) return (1) #基例在这 else return (N*fact (n-1))}# Flip String reverse <-function (s) { if (s== ') return (') #基例在这 else return (PASTE0 (reverse (substring (s,2)), substr (s,1,1))}
R Run Results
> Reverse (' Hello World ') [1] "Dlrow Olleh" > Fact (12) [1] 479001600
Spit a Groove:
Unlike the IDE of R has formed a single big situation in the R studio, Python has a lot of IDE, not very good, now with Anaconda.
Anaconda currently supports Mac OS X 10.7-10.10, last night hand remnants, upgraded the system to OS x EI Capitan 10.11.1 (15b42), and then the Idiot, Anaconda Live loading app list, can't load the app successfully This morning, the character brokeout, Spyder-app magical and can be loaded successfully.
has been learning Python3, want to practice practiced hand climb a worm, the result is a pile of pits. At present, to be able to print the Web page in text form This step, has not found and R rvest function similar to the method, can go directly into the Html_node to retrieve their desired information.
The end of The spit groove.
Recommend a python online tutorial, blogger is the Great God, Python2,python3 's tutorials are all, very comprehensive.
The Data visualisation catalogue teaches you how to use charts correctly.
To the great God wrote the Great Wall of poetry study.
Factorial and string inversion of recursive functions-based on R and Python