Re: Can someone explain vslice()'s error_control to me?
- Posted by DerekParnell (admin) Oct 24, 2014
- 1326 views
Sorry but I can't explain this "enhancement". In my opinion, not only is it overly complex, it is also a poor method to help users, and its poorly coded as well. In a word ... inappropriate.
I would have thought that this function should either return a valid "column" (vertical slice) or a meaningful error value. For example, if it returned the index of the first "row" that didn't have the requested column, it could be useful to the caller.
public function vslice(sequence source, integer colno) sequence ret if colno < 1 then return 0 -- Invalid column number requested end if ret = repeat(0, length(source)) -- Allocate space for column. -- Look at each 'row' and pick out the value of the requested 'column'. for row = 1 to length(source) do if colno > length(source[row]) then return row -- Error. This row doesn't have the requested column. end if ret[row] = source[row][colno] end for -- All good. Return the vertical slice. return ret end function