Greedy algorithm for Egyptian fractions: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: Added a functionally composed version.)
(→‎Composition of pure functions: Edited derivation of negative ratios)
Line 1,596: Line 1,596:
)) if n else Nothing()
)) if n else Nothing()
fr = Fraction
fr = Fraction
xs = unfoldr(go)(nd)
return list(
return list(map(neg, xs)) if 0 > nd else xs
map(neg, unfoldr(go)(-nd))
) if 0 > nd else unfoldr(go)(nd)