1. Replacing a vslice

Is it possible to do something like this?

sequence s = {{1,2,3},{4,5,6},{7,8,9}} 
sequence temp = vslice(s,3} 
temp = rotate(temp,ROTATE_RIGHT) 
s = replace_vslice(temp,s,3)  -- Insert the previous vslice back in s after it has been rotated 
 
-- s is {{1,2,9},{4,5,3},{7,8,6}}  
new topic     » topic index » view message » categorize

2. Re: Replacing a vslice

try this:

global function replace_vslice(sequence rep, sequence source, integer column) 
    for i=1 to length(rep) do 
        source[i][column] = rep[i] 
    end for 
    return source 
end function 
new topic     » goto parent     » topic index » view message » categorize

3. Re: Replacing a vslice

Thanks. That's pretty much what I am doing. Just wondered if there was defined routine that was faster than iterating through the sequence.

EDIT: Turns out it's plenty fast. It was the way I was using it that slowed things down.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu