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

One Line Factorial

Name: Anonymous 2009-06-15 15:56

for(int a1=1,a2=1,i=scanf_s("%d",&i)+i-1;(i--)>2; a1=(a2+=a1)-a1,(i==2)?printf_s("Result=%d\n",a2):NULL)

Name: Anonymous 2009-06-19 17:34

>>48
Using >>7's haskell:

7.hs:12:1: parse error (possibly incorrect indentation)

After fixing that:
7.hs:2:67: Not in scope: `join'
7.hs:5:23: Not in scope: `shiftR'
7.hs:5:39: Not in scope: `.&.'
7.hs:7:19: Not in scope: `genericIndex'
7.hs:17:41: Not in scope: `.&.'
7.hs:17:105: Not in scope: `join'
7.hs:18:52: Not in scope: `shiftR'
7.hs:19:64: Not in scope: `join'
7.hs:22:25: Not in scope: `join'
7.hs:26:23: Not in scope: `shiftL'


After importing Control.Monad, Data.List and Data.Bits:
7.hs:26:25:
    No instance for (Monad ((->) Integer))
      arising from a use of `join' at 7.hs:26:25-57
    Possible fix:
      add an instance declaration for (Monad ((->) Integer))
    In the first argument of `(*)', namely
        `join (*) (recFactorial $ div n 2)'
    In the expression: join (*) (recFactorial $ div n 2) * swing n
    In the definition of `recFactorial':
        recFactorial n | n < 2 = 1
                       | True = join (*) (recFactorial $ div n 2) * swing n

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