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

Can your language do this?

Name: Anonymous 2012-11-13 22:29

average = sum / genericLength

import Control.Monad
import Control.Monad.Instances
import Data.List

instance Eq (x -> a)

instance (Num a, Eq a) => Num (x -> a) where
    fromInteger = const . fromInteger
    f + g = liftM2 (+) f g
    f * g = liftM2 (*) f g
    f - g = liftM2 (-) f g
    negate = (negate .)
    abs = (abs .)
    signum = (signum .)

instance (Eq a, Fractional a) => Fractional (x -> a) where
    f / g = liftM2 (/) f g
    recip = (recip .)
    fromRational = const . fromRational

Name: Anonymous 2012-11-13 22:30

what does it do? too much syntax. Lisp is all I can take for my puny brain.

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