[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Language Syntax
- From: Lucas <cad.lua@...>
- Date: Tue, 24 Jun 2014 03:58:57 -0300
OK, my fault, I thought you just indented my code, I see it only
evaluates once...
and thanks again...
On Tue, Jun 24, 2014, at 02:43, Choonster TheMage wrote:
> On 24 Jun 2014 13:52, "Lucas" <cad.lua@lucasjr.nospammail.net> wrote:
> >
> > Ok, my intention was to write such a function
> >
> > function modulus(n, d) return n - (q = math.floor(n/d)) * d, q; end
> >
> > is there any means to write it down just as simple?
> >
> > r, q = modulus(10, 3)
> >
>
> Sticking with your existing technique:
> function modulus(n, d)
> local q = math.floor(n/d)
> return n - q * d, q
> end
>
> Using the modulus operator (I'm pretty sure this is correct):
> function modulus(n, d)
> return n % d, math.floor(n/d)
> end
>
> Regards,
> Choonster
>