http://qs321.pair.com?node_id=180356


in reply to Re: A better mod (%) operator?
in thread A better mod (%) operator?

It wasn't really a "search for speed" that drove the thought, it was more elegance, orthogonality and that it bugs me that I know that the 'other part of the equation' is sitting there in a register somewhere but I have to do the division again to get it.

Down the years, It seems that almost every time I have made use of the mod operator, I have also done a div with the same parameters.

Finally using Perl, I have a language that could elegantly provide me with both halves of the equation in one pass and render the elegance that comes with it.

I hadn't thought about the expense of constructing the return list. Is it possible to "re-use" the inbound @_ list? Would there be any benefit in doing so?

I wonder how constructing a new list would compare (at the inner levels) with duplicating the whole inbound/outbound stack frames etc.? Possibly little in it?

Basically, I don't yet know enough to judge and am not ready to go digging deep enough to get the answers.

T'was just an idea:^).