/*-------------------------------------------------- created by st10 at Tue Oct 25 13:57:59 PDT 2016 --------------------------------------------------*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> #include "is_empty.h" #include "first.h" #include "rest.h" using namespace std; /*-------------------------------------------------- signature: silly_length : string -> int purpose: expects a string and returns the number of characters in that string (in a silly fashion) examples: silly_length("") == 0 silly_length("clown") == 5 silly_length("t") == 1 --------------------------------------------------*/ int silly_length(string a_string) { if (is_empty(a_string)) { return 0; } else { return 1 + silly_length( rest(a_string) ); } }