Hi!
Does New Path Forms in Version 2.5.55 suits your needs?
In the same way you can access multi-dimentional blocks
like this :

>> data: [ [7 9] [5  3]]
== [[7 9] [5 3]]
>> i: 1
== 1
>> n: 2
== 2
>> data/(i)/(n)
== 9
>> data/(i)/(i + 1): 13
== 13
>> data/:i/:n
== 13
>> data/:i/:i: 19
== 19
>> data
== [[19 13] [5 3]]

Karol


----- Original Message ----- 
From: "Jeff Massung" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 21, 2006 1:34 AM
Subject: [REBOL] New version of AT


> So, one of the few frustrations I've had with REBOL has been in regards to
> multi-dimentional array manipulation. I haven't found anything in the 
> REBOL
> dictionary to do what I want, so I put together a simple utility function
> (PEEK, my own version of AT). I thought I'd post it here real quick, and 
> see
> if the basic functionality I'm looking for already exists (and if not,
> why?).
>
> The basic idea is to use one function to both access and set values in
> multi- (or one-) dimensional array. I'm kind of borrowing this from Lisp's
> (aref ...) and (setf (aref ...) value). The general idea being that you 
> can
> pass an integer, a pair, or a block of indices and it will traverse the
> array and finally get or set the value.
>
> peek: func [ "Gets/sets the value from a multi-dimensional array."
>    block [ block! ] "Multi-dimensional array"
>    index [ integer! pair! block! ] "Offset(s) into the array"
>    /! value [ any-type! ] "Value to replace index with"
> ] [
>    either ! [
>        switch type?/word index [
>            integer! [ change at block index value ]
>            pair! [ change at pick block first index second index value ]
>            block! [
>                either (length? index) = 1 [
>                    change at block first index value
>                ] [
>                    peek/! pick block first index next index value
>                ]
>            ]
>        ]
>    ] [
>        switch type?/word index [
>            integer! [ pick block index ]
>            pair! [ pick pick block first index second index ]
>            block! [
>                either (length? index) = 1 [
>                    pick block first index
>                ] [
>                    peek pick block first index next index
>                ]
>            ]
>        ]
>    ]
> ]
>
> As I'm still learning REBOL, I'm hoping for some critiques and 
> suggestions.
> But any hints as to why this functionality isn't there to begin with (if 
> it
> isn't that is), would be good too. :-)
>
> Thanks!
>
> Jeff M.
>
> --
> [EMAIL PROTECTED]
>
> -- 
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
> 

-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to