Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

callCC oddness

Name: dddddddddddddddddddddddd 2007-03-31 15:40 ID:HM1BiqY2

for some reason

fac n = (`runCont` id) $
          callCC $ \k -> do
            when (n == 1) $ k 1
            return $ n * fac (n - 1)


is faster and uses less memory (for n=10000) than

fac' = product . enumFromTo 1

or [code]fac'' n = foldr1 (*) [1..n]

what gives /prog/?

Name: Anonymous 2007-04-01 2:41 ID:qpfSC7D5

>>14 here
How embarassing, seems like I misread. An add reg, imm is 2 cycles, just like an inc. However, it is shorter to type inc, so you save a few bytes on disk.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List