Skip to content

Instantly share code, notes, and snippets.

@usev6
Created November 17, 2015 22:37
Show Gist options
  • Save usev6/132c79cefca8ce12607d to your computer and use it in GitHub Desktop.
Save usev6/132c79cefca8ce12607d to your computer and use it in GitHub Desktop.
first element of $indices is (Any) here
use nqp;
my \iter = (3,2,1,4).iterator;
my \sort-buffer = IterationBuffer.new;
unless iter.push-until-lazy(sort-buffer) =:= IterationEnd {
fail X::Cannot::Lazy.new(:action<sort>);
}
my int $i = 0;
my int $n = sort-buffer.elems;
my $transform = False;
say $n;
my $indices := nqp::list;
nqp::setelems($indices,$n);
nqp::bindpos($indices,$i,nqp::decont($i)) while ++$i < $n;
say $indices;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment