Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using large lists or arrays in QM
#1
Hello - 

I have a list of about 1,000 coordinate pairs that I would like to treat as a two dimensional array in QM. I'm looking for help in syntax to store a variable like that.

In other languages I would expect to be able to do something like coordinatePairs = [[x1,y1],[x2,y2]...] so that I could call coordinatePairs[0][0] to get x1. I've done some research in the documentation but can only seem to find how to populate empty Arrays programmatically, not when they are declared. 

Any help would be great!
 xCoord  yCoord
5393  109
5393  114
5393  115
5393  116
5393  117
5393  118
5394  109
5394  110
5394  111
#2
Also, if it helps for context - I'm trying to implement A* pathfinding algorithm with those coordinates

After a bit more thought, I realized I may be able to use csv functions for this
I'm going to build something based on this thread
#3
Yes, QM does not have array initializers. Can be used CSV.

Function InitArray_int_2D
Code:
Copy      Help
;/
function $csv ARRAY(int)&a

;Creates ARRAY(int) of 2 dimensions (columns, rows) from a CSV string.

;EXAMPLE
;str csv=
;;1,2,  3,4
;;5,6,  7,8
;;9,10,  11,12
;;13,14,  15,16
;ARRAY(int) a
;InitArray_int_2D csv a
;
;;results
;int row
;for row 0 a.len
,;out F"{a[0 row]},{a[1 row]},  {a[2 row]},{a[3 row]}"


ICsv c._create
c.FromString(csv)
a.create(c.ColumnCount c.RowCount)
int i j
for i 0 a.len
,for j 0 a.len(1)
,,a[j i]=c.CellInt(i j)


Forum Jump:


Users browsing this thread: 1 Guest(s)