[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: assignment in conditional expression?
- From: lhf@... (Luiz Henrique de Figueiredo)
- Date: Tue, 8 Dec 1998 21:48:19 -0200 (EDT)
>From: David Jeske <jeske@home.chat.net>
>
>I'm sorry, in all my examples I never once used the feature I wanted
>to have, because I didn't actually _do_ anything in any of the
>loops. Lets try again:
>
>function correlate_data(tbl1,tbl2)
> local output_tbl = {};
>
> for(1,2,macro(x)
> output_tbl[x] = tbl2[tbl1[x]];
> end);
>
> return (output_tbl);
>end
this is where upvalues enter! check this out:
function correlate_data(tbl1,tbl2)
local output_tbl = {};
for(1,2,function (x) -- use the 'for' *function*
%output_tbl[x] = %tbl2[%tbl1[x]]; -- see the upvalues!
end);
return (output_tbl); -- no need for parentheses here
end
this should work.
--lhf