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

Syntax for typed lamdas

Name: Anonymous 2012-06-09 21:56

Help me /prog/, i'm making a language and i can't decide on what syntax to use for typed lambdas

Name: Anonymous 2012-06-11 13:15

>>18
only a lisp weenie would consider going into an infinite loop and using up all available memory when given unexpected input to be acceptable. this is why lisp will never be used for anything serious.

here's a better factorial:
factorial = (\n -> product [2..n])

and here's a much faster one:
genericShiftL n b | b <= fromIntegral (maxBound :: Int) = shiftL n $ fromIntegral b
                  | otherwise = genericShiftL (shiftL n maxBound) (b - fromIntegral (maxBound :: Int))

genericShiftR n b | b <= fromIntegral (maxBound :: Int) = shiftR n $ fromIntegral b
                  | otherwise = genericShiftR (shiftR n maxBound) (b - fromIntegral (maxBound :: Int))

bitCount 0 = 0
bitCount n = bitCount (genericShiftR n 1) + n .&. 1

facSwing n | n < 33 = genericIndex smallOddSwing n
           | True   = product pList
    where smallOddSwing = [1, 1, 1, 3, 3, 15, 5, 35, 35, 315, 63, 693, 231, 3003, 429, 6435, 6435, 109395, 12155, 230945, 46189, 969969, 88179, 2028117, 676039, 16900975, 1300075, 35102025, 5014575, 145422675, 9694845, 300540195, 300540195]
          pListA q p prime = let x = div q prime in case x of
                                                         0 -> case p of
                                                                   1 -> []
                                                                   _ -> [p]
                                                         _ -> pListA x (p * prime ^ (mod x 2)) prime
          pListB = (filter ((1==) . flip (.&.) 1 . div n) . takeWhile (<= div n 3) $ dropWhile ((<= n) . join (*)) primes)
          pListC = takeWhile (<= n) $ dropWhile (<= genericShiftR n 1) primes
          pList = (concatMap (pListA n 1) . takeWhile ((n >=) . join (*)) $ tail primes) ++ pListB ++ pListC

recFactorial n = if n < 2 then 1 else join (*) (recFactorial $ genericShiftR n 1) * facSwing n

factorial = liftM2 genericShiftL recFactorial $ ap (-) bitCount

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