array coordinates
[1/3] from: cyoungbl::legato::com at: 8-Aug-2001 15:11
I've created a simple array block like this:
board-state: [
[ r r r r ]
[ r r k r ]
[ r r r r ]
[ 0 0 0 0 ]
[ 0 0 0 0 ]
[ b b b b ]
[ b j b b ]
[ b b b b ]
]
When trying to access an array element, the syntax is pretty convoluted.
For example, I've been accessing x-y coordinates in the array like this:
pick pick board-state y x
I'm a neophyte with REBOL, so I don't doubt that there may be an easier way.
What happened to C or Pascal's easy notation?
board-state[x][y]
Thanks,
Carl
[2/3] from: ryanc:iesco-dms at: 8-Aug-2001 14:28
Try some of these...
>> board-state/2/3
== k
>> x: 2 y: 7
== 7
>> board-state/:y/:x
== j
>> state: func [x y] [pick pick board-state y x]
>> state 3 4
== 0
>>
--Ryan
Carl Youngblood wrote:
> I've created a simple array block like this:
> board-state: [
<<quoted lines omitted: 19>>
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
--
Ryan Cole
Programmer Analyst
www.iesco-dms.com
707-468-5400
[3/3] from: brett:codeconscious at: 9-Aug-2001 12:24
> When trying to access an array element, the syntax is pretty convoluted.
> For example, I've been accessing x-y coordinates in the array like this:
>
> pick pick board-state y x
Looks pretty straightforward.
> I'm a neophyte with REBOL, so I don't doubt that there may be an easier
way.
> What happened to C or Pascal's easy notation?
>
> board-state[x][y]
>> board-state/8/4
== b
>> i: 4
== 4
>> i: 8
== 8
>> j: 4
== 4
>> board-state/:i/:j
== b
Brett.
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted