gmauer
2021-10-23 17:32:49

given an array is there a way to get a list/array/sequence/whatever of each value and its associated index? Similar to .items() in python or Object.fromEntries() (or even just map) in js?


sorawee
2021-10-23 17:34:00

Are you talking about array from the math library, or the actual “array” for Racket which is called vector?


gmauer
2021-10-23 17:34:17

from the math library



soegaard2
2021-10-23 17:35:14

(used in a for-loop)


gmauer
2021-10-23 17:36:30

ah, yes, I think that could work


gmauer
2021-10-23 17:36:44

I actually think I tried searching that too, but searched in-array-indicies


soegaard2
2021-10-23 17:38:27

I use indices too. According to https://www.nasdaq.com/articles/indexes-or-indices-whats-the-deal-2016-05-12 it’s even the “mathematical” spelling.


soegaard2
2021-10-23 17:45:13

It would be nice if the elements in in-array and in-array-indexes match. They probably do.


notjack
2021-10-23 21:43:31

There’s in-indexed which works with any sequence


gmauer
2021-10-23 22:04:22

not with array it would seem #+begin_src racket <<racket/my-imports>> (define board (list*->matrix '((water water water water) (water water land water) (land land land water) (water land water water) (land land water water)))) (~> board in-indexed sequence->list) #+end_src #+RESULTS: : in-indexed: contract violation : expected: sequence? : given: (array #[#['water 'water 'water 'water] #['water 'water 'land 'water] #['land 'land 'land 'water] #['water 'land 'water 'water] #['land 'land 'water 'water]]) : context...: : /tmp/ob-racket-wqzp30/ob-racketcNUWZZrkt:22:4 : body of "/tmp/ob-racket-wqzp30/ob-racketcNUWZZrkt"


notjack
2021-10-24 03:11:48

it’s meant for 1d sequences