Notes for Lecture 19 on December 8, 2020
Recursion Examples
Length of a string:
length(
str
)
Also see the function
length(
s
)
in
recfun.py
Maximum of a list:
maxim(
numlist
)
Also see the function
largest(
l
)
in
recfun.py
Reverse a string:
rev(
str
)
Also see the function
revstr(
s
)
in
recfun.py
Is a string a palindrome:
ispal(
str
)
Also see
palindrome.py
Sum of digits of number in string form:
sumofdigits(
str
)
Sum of digits of number in integer form:
sumofdigits2(
num
)
Also see
sumdigits.py
Matt Bishop
Office: 2209 Watershed Science
Phone: +1 (530) 752-8060
Email:
mabishop@ucdavis.edu