lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, May 14, 2009 at 9:13 PM, Steven Johnson
<> wrote:
>> Any other operations that make sense with generic rank 2 arrays, which
>> are not specialized matrix operations?
> - swap_rows() / swap_cols(), perhaps?

Yes, exactly. None of these operations are difficult to do in Lua, but
it is good to have them as explicitly named functions.

Other operations can be easily made up using e.g. list comprehensions.
This gives you the even columns:

map(C'x for x if x % 2 == 0',A)

> - Something to fill all elements in a slice with a value. (This could
> also apply to your other containers.)

Yes, List.assign_slice  represents the cool Python feature L[i:j] =
ls, but there's an obvious other operation to set a slice to a
constant value, and naturally both of these generalize to 2D.

> - A slice iterator. Might be redundant, though more lightweight, if
> you do the slice extraction thing.

Yes, a slice is a copy, whereas the iterator would be a cousin of
array.iter(), which gives you i,j and value.

BTW, I'm thinking about changing the name of 'array' to 'array2d'.
'table' is obviously out ;)

steve d.