Arie Groeneveld wrote:
:
| Looking at the result of my rewriting gives me the idea it isn't
| Haskelly enough.
|
| Anyways, here's my interpretation:
|
| -- period m/n base = (period length, preperiod digits, period digits)
| period :: Integer -> Integer -> Integer -> (Int, ([Integer], [Integer]))
:
Haskelliness
I'd be inclined to try using a Rational (from Data.Ratio) and the
properFraction function, instead of numerators and denominators and gcd.
You could do away with the parts where you subscript a linked list, if
you did something with elem and zip and span instead of findIndex and
splitAt.
Instead of translating Nothing to -1 and Just i to i, you could use
the result of findIndex directly in a case expression.
Correctness
*Main> period 8 70 10
(6,([0],[5,7,1,4,2,8]))
That should be (6,([1],[1,4,2,8,5,7])).
Regards,
Tom
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe