Skip to content

Instantly share code, notes, and snippets.

@samcv
Created January 17, 2017 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samcv/3661ba40798e613b5e1d96756ee1767f to your computer and use it in GitHub Desktop.
Save samcv/3661ba40798e613b5e1d96756ee1767f to your computer and use it in GitHub Desktop.
use nqp;
my str $string = "this,that,other,thing," x 100;
my int $chars = nqp::chars($string);
my $i := nqp::add_i(0,0);
$i := nqp::add_i(0, 50);
nqp::while(nqp::isle_i($i, $chars), (
$string = nqp::replace($string, nqp::index($string, ',', $i), 1, ",\n");
$i := nqp::add_i($i, 50);
)
);
say $string;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment