Brainfade time - what's the proper name for a 'local' handler?

Robert Mann rman at
Thu May 27 15:10:33 EDT 2010

>   // Return a list of all books with at least 'threshold' copies sold. 
>   function bestSellingBooks(threshold) { 
>     return bookList.filter( 
>         function (book) { return book.sales >= threshold; } 
>       ); 
>   } 

did I get it right?? as I understand it, the "closure" replaces a loop?
Assuming the function book loops through the books?

for the example I assume we have a pile of cards for each book...

function bestSellingBooks threshold
put the number of cards of stack books into numberOfBooks
put empty into theResult

for i = 1 to numberOfBooks
put field theSales of card i into @iSales
 put booklistFilter (threshold, @sales) after theResult
end loop

return theResult
end function

function bookListFilter threshold, sales

     if sales > threshold then return sales &"," else return empty

end function

if that is right, yeak closure is more compact & elegant!
but did I miss something? brainfade!

View this message in context:
Sent from the Revolution - User mailing list archive at

More information about the Use-livecode mailing list