Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10133

Re: Partition string into length n chunks

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Partition string into length n chunks
Date 2012-05-18 09:29 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jp54qj$gpg$1@smc.vnet.net> (permalink)
References <201205170811.EAA05083@smc.vnet.net>

Show all headers | View raw


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@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.
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Partition string into length n chunks Bob Hanlon <hanlonr357@gmail.com> - 2012-05-18 09:29 +0000

csiph-web