Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Paths, Arrays, Assignment and other bothersome things

 [1/3] from: james:mustard at: 17-Dec-2001 14:00


Hi All, At present I am using the following to assign to an array: REBOL [] grid: array/initial [8 8 8] false random/seed now for z -3 2 1 [ for y -3 2 1 [ for x -3 2 1 [ do reform join "grid/" [x + 5 "/" y + 5 "/" z + 5 ": random true"] ] ] ] print grid halt This works fine but seems to be a rather round-about way to achieve the assignment. Is there a better way? Ideally I would like to have used something like: -> grid/:x/:y/:z: random true but this only gives a get error. James.

 [2/3] from: larry::ecotope::com at: 16-Dec-2001 19:01


Hi James, The problem is that the path notation does not allow an element to indicate both a GET and a SET. This will supposedly be fixed in the next version of REBOL. You could try: poke grid/:x/:y z random true ;only get-words in path or poke pick pick grid x y z random true or if the indices need to be calculated: poke pick pick grid x + 5 y + 5 z + 5 random true POKE and PICK are the native block element manipulation functions and produce faster code than the path notation. BTW FOR is vary slow, it is better to use REPEAT or FOREACH when possible. HTH -Larry

 [3/3] from: james:mustard at: 17-Dec-2001 17:39


Thanks for that - I was wondering if it was a bug or I was doing something in a non-rebol way :)