
29 Sep
2007
29 Sep
'07
2:26 p.m.
On Sat, Sep 29, 2007 at 03:11:20PM +0100, PR Stanley wrote:
Hi ord :: Char -> Int ord c = sum [1 | x <- ['\0'..'\255'], x < c]
Any comments? Any alternatives? Cheers, Paul
It's waay slow, it breaks for characters >255. ord :: Char -> Int ord = fromEnum As Char is an instance of 'Enum'. If you think this is cheating, then consider that (<) for Char is probably implemented using ord on some level. You need primitives somewhere... Stefan