reading half part of a table

Posted by eastafri on Stack Overflow See other posts from Stack Overflow or by eastafri
Published on 2010-06-08T09:08:45Z Indexed on 2010/06/08 9:12 UTC
Read the original article Hit count: 208

Filed under:

When i have a table;

1 0 0 1 0
0 1 0 1 0
0 0 1 0 1
1 1 1 1 0
0 0 0 0 1

Say i want to only read and keep the values along the upper diagonal of this table, how can i easily accomplish this in pure ruby?

Such that the final structure looks like

1 0 0 1 0
  1 0 1 1 
    1 0 1
      1 0
        1

Thanks

© Stack Overflow or respective owner

Related posts about ruby