[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Microlight
- From: Peter Aronoff <telemachus@...>
- Date: Tue, 18 Dec 2012 09:18:34 -0500
On Tue Dec 18 2012 @ 2:48, Philipp Janda wrote:
<snip>
> And everything because you want to write:
>
> map( filter( t, is_odd ), function( _, v ) print( v ) end )
>
> instead of:
>
> for i,v in ipairs( t ) do
> if is_odd( i ) then
> print( v )
> end
> end
Very well argued and explained. I will have to chew on that a bit. Perhaps
I'll keep moving on the road towards minimalism. :)
> Can't say anything about partition, though, since I don't know what
> it's supposed to do.
It's essentially a `filter` or `select` function, except that it returns
two lists (tables in Lua): the list of items that match a predicate - as
with `filter` - and a second list of items that don't match. (Makes for an
easy way to split a list into two groups and then hand the results over to
different functions for processing.)
http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-partition
Thanks, P
--
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System