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

What good are trees?

Name: Anonymous 2010-05-28 14:55

I've never had to use them.

Name: Anonymous 2010-05-29 4:31

>>19
many languages do have a separate character type, but that character type is almost always an integral type.
in haskell this is not the case, until you do something like this:
both :: Arrow a => a b c -> a (b, b) (c, c)
both = join (***)

instance Num Char where
    fromInteger = chr . fromInteger
    (+) = ((chr . flip mod (ord maxBound + 1) . uncurry (+)) .) . curry (both ord)
    (*) = ((chr . flip mod (ord maxBound + 1) . uncurry (*)) .) . curry (both ord)
    (-) = ((chr . flip mod (ord maxBound + 1) . uncurry (-)) .) . curry (both ord)
    negate = chr . (ord maxBound + 1 -) . ord
    abs = id
    signum = chr . signum . ord

instance Real Char where
    toRational = toRational . ord

instance Integral Char where
    quotRem = ((both chr . uncurry quotRem) .) . curry (both ord)
    toInteger = toInteger . ord


too bad schemers are stuck with their http://en.wikipedia.org/wiki/Scheme_(programming_language)#Disjointness_of_primitive_datatypes.

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