[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: 2D Array Operations (was [ANN] Penlight 0.7)
- From: steve donovan <steve.j.donovan@...>
- Date: Fri, 15 May 2009 11:00:55 +0200
On Thu, May 14, 2009 at 9:13 PM, Steven Johnson
<steve@xibalbastudios.com> 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.