kachayev / fn.py

Functional programming in Python: implementation of missing features to enjoy FP
Other
3.35k stars 204 forks source link

Bugfix underscore repr #57

Closed Digenis closed 10 years ago

Digenis commented 10 years ago

This fixes two bugs in the way __repr__ parses the returned value of __str__.

It splits the result on '=>' but not just on the first valid one. It goes on inside the expression on the right which may contain a literal '=>'. It also replaces the function arguments with _ but the regex doesn't exhaust the digits of the argument's base. For more than nine arguments, leftover digits from the base remain.

I include test cases for both bugs.

I put them in the same PR branch because they affect the exact same line.

Digenis commented 10 years ago

Only the lack of a builtin reduce() in some python3 versions causes the build to fail. Should I cherry-pick 50c2584ab2cf77d4c1c5d3aef9c9a22a8b41a471 from #51 to make Travis happy before you review it?

kachayev commented 10 years ago

I've fixed problem with reduce already. Thanks for your PRs!