Tags: %TAGME{ tpaction="" web="SCMP118" tag="" }% view all tags


In this activity we will write and test a simple recursive function.


string str = "Kenyon College";

We can define the reverse of a string:

rev(str) = str  if str.length() <= 1
= str[str.length()-1] + rev(str.substr(1,str.length()-2) + str[0];

Why is this right?

Can we write and test this in a function?

Topic revision: r1 - 2017-05-02 - JimSkon
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback