[Haskell-cafe] Re: Roman Numerals and Haskell Syntax abuse
George Russell
ger at informatik.uni-bremen.de
Tue Jul 6 02:13:20 EDT 2004
George Russell wrote:
> The following declaration for a function for converting positive
> integers to Roman numerals is 181 characters long.
>
> Is there a shorter one?
Yes, thanks to various contributors to this list, the shortest is now
148 characters!!
roman=f 0;f a n|n<1=""|n>=t!!a=s!!a:f a(n-t!!a)|n+t!!b>=t!!a=s!!b:f a(n+t!!b)|1>0=f(a+1)n where b=2*div a 2+2;s="mdclxvi";t=[1000,500,100,50,10,5,1]
More information about the Haskell-Cafe
mailing list