MathGroup Archive 2012

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

Search the Archive

Re: Partition string into length n chunks

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126549] Re: Partition string into length n chunks
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Fri, 18 May 2012 05:27:10 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201205170811.EAA05083@smc.vnet.net>

A single argument function doesn't need an explicit argument when mapped

chunk[s_String, n_Integer] :=
 StringJoin /@ Partition[Characters[s], n]


Bob Hanlon


On Thu, May 17, 2012 at 4:11 AM, David G <daggillies at gmail.com> wrote:
> I am sure this is trivially simple, but how do I partition a string into non-overlapping length n chunks? The best I could come up with is chunk[s_, n_] := StringJoin[#] & /@ Partition[Characters[s], n] but this seems overly long-winded.
>



  • Prev by Date: problem with Manipulate
  • Next by Date: export to .m using a cell command
  • Previous by thread: Partition string into length n chunks
  • Next by thread: Re: Partition string into length n chunks