Discussion:
grid and list
Add Reply
Jens Kallup
2020-07-17 10:51:26 UTC
Reply
Permalink
Hello,

assume, I have a grid: y=20 x x=20:

1. How can I define/declare it ?
2. How can I add values into the grid ?

Note:
- I have
Point at (y=4; x= 5), and a
Point at (y=4; x=10):

How can I insert these points to the grid,
when the initial grid Points have value 0?

Jens
Jeff Barnett
2020-07-17 18:21:25 UTC
Reply
Permalink
Post by Jens Kallup
Hello,
1. How can I define/declare it ?
2. How can I add values into the grid ?
- I have
  Point at (y=4; x= 5), and a
  How can I insert these points to the grid,
  when the initial grid Points have value 0?
Why not use a 2D array? You can then use whatever you like to represent
a grid point and a NIL value will represent an empty point. I assume
that you are asking your question in the context of the Lisp programming
language: most Lisp implementations provide arrays. If your grid is
large and is only sparsely occupied, you can use a hash array: the key
is a list such as (x y) and element values are whatever you like. Most
Lisp implementations provide hash arrays. Consulate the documentation of
whatever system you are using for details.
--
Jeff Barnett
t***@google.com
2020-07-17 22:45:43 UTC
Reply
Permalink
Post by Jens Kallup
Hello,
1. How can I define/declare it ?
2. How can I add values into the grid ?
- I have
Point at (y=4; x= 5), and a
How can I insert these points to the grid,
when the initial grid Points have value 0?
Here would be one CommonLisp solution for the most natural representation,
namely a 2D array.

(defparameter *grid* (make-array '(20 20) :initial-element 0))

(setf (aref *grid* 5 4) VALUE)
(setf (aref *grid* 10 4) VALUE)
g***@gmail.com
2020-07-18 08:05:29 UTC
Reply
Permalink
Post by Jens Kallup
Hello,
1. How can I define/declare it ?
2. How can I add values into the grid ?
- I have
Point at (y=4; x= 5), and a
How can I insert these points to the grid,
when the initial grid Points have value 0?
I use a RELATIONAL TABLE

nn X Y VALUE


1st I enter a small array manually

node 1
node 2
node 3
node 4
node 5


nn2 does 5 loops!

nn2 M
-node N
-assert nn M N 4
-clear N
-next
-nn2 M


nn3 does 5 loops calling nn2 each iteration

nn3
-node X
-nn2 X
-clear X
-next
-nn3


RESULT

nn 1 1 4
nn 1 2 4
nn 1 3 4
nn 1 4 4
nn 1 5 4
nn 2 1 4
nn 2 2 4
nn 2 3 4
nn 2 4 4
nn 2 5 4
nn 3 1 4
nn 3 2 4
nn 3 3 4
nn 3 4 4
nn 3 5 4
nn 4 1 4
nn 4 2 4
nn 4 3 4
nn 4 4 4
nn 4 5 4
nn 5 1 4
nn 5 2 4
nn 5 3 4
nn 5 4 4
nn 5 5 4



Then I use

remove nn X Y
assert nn X Y 1

to populate specific points with values

www.miniBASE.com
Jens Kallup
2020-07-18 10:41:08 UTC
Reply
Permalink
thank you All

Jens

Loading...