MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

partitioning a string

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60932] partitioning a string
  • From: Sara <ma_sara177 at hotmail.com>
  • Date: Tue, 4 Oct 2005 01:24:58 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I have tred to partition a String and iwrote this code but its take to time to run, and it doesnt show eny result.
stringPartition[s_, n_] := Module[{}, emptyString = Mod[StringLength[s], n];
    If[emptyString != 0, empt = n - emptyString];
    str1 := " ";
    str2 := "";
    For[i = 1, i <= empt, i++, str2 = str2 <> str1];
    str = s <> str2;
    M = StringLength[str];
    yasList = Range[1, M/n] ; 
    For[i = 1, i <= M, i + n, For[j = 1, j <= M/n, j++,
          yasList[[j]] = StringTake[i, j*n]
               ];
           ];


  • Prev by Date: Pure Function for String Selection
  • Next by Date: Re: How to "search" in a matrix?
  • Previous by thread: Re: Pure Function for String Selection
  • Next by thread: Re: partitioning a string