Created
April 22, 2018 17:04
-
-
Save Vindaar/30f0e998bd5c8c79c6df37cf40d81ac0 to your computer and use it in GitHub Desktop.
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
import sequtils | |
proc `[]`*[T](a: openArray[T], inds: seq[int]): seq[T] {.inline.} = | |
## given two openArrays, return a sequence of all elements whose indices | |
## are given in 'inds' | |
## inputs: | |
## a: seq[T] = the sequence from which we take values | |
## inds: openArray[int] = the array which contains the indices for the | |
## arrays, which we take from 'array' | |
## outputs: | |
## seq[T] = a sequence of all elements s.t. array[ind] in numpy indexing | |
result = newSeq[T](inds.len) | |
for i, ind in inds: | |
result[i] = a[ind] | |
let a = toSeq(0..100) | |
echo a[toSeq(countup(3, 50, 7))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment