Advertisement
swarley

Untitled

Aug 29th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. // Modeled after take (cycle str) from haskell
  2. string
  3. takeCycle( string &pattern, int length )
  4. {
  5.     string output = "";
  6.     int tmpLen;
  7.  
  8.     // Use a temporary int to preserve `length`
  9.     for ( tmpLen = length ; tmpLen > 0; tmpLen-- )
  10.     {
  11.         output.append( pattern, 0, 1 );
  12.         rotateStringLeft( pattern );
  13.     }
  14.  
  15.     return output;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement