Created
November 16, 2016 19:02
-
-
Save lizmat/916dd334cce318b3ae0594afbe537214 to your computer and use it in GitHub Desktop.
nqp::atpos works differently between normal and shaped arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nqp; | |
sub reverse(\a,\b) { | |
my int $elems = a.elems max b.elems; | |
my int $last = $elems - 1; | |
my Mu $a := nqp::getattr(a,List,'$!reified'); | |
my Mu $b := nqp::getattr(b,List,'$!reified'); | |
for ^$elems -> int $i { | |
nqp::bindpos( | |
$b, | |
nqp::sub_i($last,$i), | |
nqp::atpos($a,$i) # for normal array | |
# nqp::decont(nqp::atpos($a,$i)) # for shaped array | |
) | |
} | |
b | |
} | |
my @a[5] = ^5; | |
my @b[5] = ^5; | |
@a = reverse(@a,@b); | |
dd @a, @b; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment