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] ]; ];
- Follow-Ups:
- Re: partitioning a string
- From: János <janos.lobb@yale.edu>
- Re: partitioning a string