Anonymous user
Fraction reduction: Difference between revisions
m
→{{header|Haskell}}: this foldr is just a map and filter which can be written as a list comprehension
m (→{{header|Haskell}}: this foldr is just a map and filter which can be written as a list comprehension) |
|||
Line 1,379:
findReductions :: Fraction -> [Reduction]
findReductions z@(n1, d1) =
let n2 = dropDigit x n1▼
▲ sharedDigits = digits 10 n1 `intersect` digits 10 d1
d2 = dropDigit x d1▼
decimalWithDrop = realToFrac n2 / realToFrac d2,▼
where dropDigit d = digitsToIntegral . delete d . digits 10
▲ n2 = dropDigit x n1
▲ d2 = dropDigit x d1
▲ decimalWithDrop = realToFrac n2 / realToFrac d2
findGroupReductions :: [Int] -> [Reduction]
|