
18 Oct
2012
18 Oct
'12
1:54 p.m.
On 12-10-18 05:24 AM, Serge D. Mechveliani wrote:
And concerning this example: I am not even sure now that it worths to setting $! there. Because I deliberately program qRem as returning a pair (quot, rem), and do not program a separate function for rem. And to obtain rem, one applies snd (qRem n m), and due to laziness, quot does not spend the cost. I do not know, may be, using $! may damage this style.
snd (quot, rem) does not spend the arithmetic cost of quot, but spends the memory cost of quot. Memory cost is not just occupation of memory, but also writing of memory and computing of addresses, which is not exactly cheaper than arithmetic.