Huh! How on earth did you come up with that?
Weirdly (or not) it adapts to the variables in my use case.
Splitting the sequence into 2 parts or 8 parts is a logical extension:
[0] Perl> print join ' ', map $_^14, 0..15;; 14 15 12 13 10 11 8 9 6 7 4 5 2 3 0 1 [0] Perl> print join ' ', map $_^8, 0..15;; 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7
And works for longer sequences (provided they are powers of two; which is a distinct possibility for my purpose):
[0] Perl> print join ' ', map $_^8, 0..31;; 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 24 25 26 27 28 29 30 31 16 17 18 + 19 20 21 22 23 [0] Perl> print join ' ', map $_^16, 0..31;; 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 1 2 3 4 5 6 7 8 9 10 + 11 12 13 14 15 [0] Perl> print join ' ', map $_^24, 0..31;; 24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23 8 9 10 11 12 13 14 15 +0 1 2 3 4 5 6 7 [0] Perl> print join ' ', map $_^28, 0..31;; 28 29 30 31 24 25 26 27 20 21 22 23 16 17 18 19 12 13 14 15 8 9 10 11 +4 5 6 7 0 1 2 3 [0] Perl> print join ' ', map $_^30, 0..31;; 30 31 28 29 26 27 24 25 22 23 20 21 18 19 16 17 14 15 12 13 10 11 8 9 +6 7 4 5 2 3 0 1
Just a shame it produces out-of-bounds values for non-powers-of-two:
[0] Perl> print join ' ', map $_^10, 0..19;; 10 11 8 9 14 15 12 13 2 3 0 1 6 7 4 5 26 27 24 25
In reply to Re^2: More simple math.
by BrowserUk
in thread More simple math.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |