Re: Partition(divid string to substring
- To: mathgroup at smc.vnet.net
- Subject: [mg60951] Re: Partition(divid string to substring
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Wed, 5 Oct 2005 02:27:51 -0400 (EDT)
- Organization: Uni Leipzig
- References: <dht4h7$hnr$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
I also don't know how to use StringTake[] and I
don't know what the
For[] loop does and what the empty Module[{},___]
may be mean but
StringPartition[str_String, n_Integer] :=
StringJoin @@@ Partition[PadRight[Characters[#],
StringLength[#] + n - Mod[StringLength[#], n], "
"], n] &[str]
may help you, without For[], StringTake[] or
Module[]
Regards
Jens
"Sara" <ma_sara177 at hotmail.com> schrieb im
Newsbeitrag news:dht4h7$hnr$1 at smc.vnet.net...
|I have to canstruct a method stringPartition[s,n]
that divides a string s into substrings of length
n. The last string shall be filled with spaces to
the specified length.and I have too use
StringTake. But i have done it Like that:
| 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;
| strCode = ToCharacterCode[str, "UTF8"];
| textPartition = Partition[strCode, n];
| textCode = FromCharacterCode[textPartition,
"UTF8"]
| ]
| and its work, but I dont know how to use
Stringtake instead (toCharacterCode), I dont want
to use Toharachtercode.
| Thanks
|