kachayev / fn.py

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

Lazily evaluate Stream slices #15

Closed danielhfrank closed 11 years ago

danielhfrank commented 11 years ago

This pull request is meant to resolve #6. Right now I've just added a test for the behavior we want to accomplish (which may not even be entirely accurate, but is at least a start).

Right now slicing a Stream seems to return a slice of the underlying collection, which you have implemented as a list. In order to make this lazily evaluated, I was wondering what you thought should be the return type. We could either return a new Stream based off the parameters of the index, or simply a generator. My inclination is to do the former, but I'm open to other suggestions.

Your presentation on Functional Programming totally changed the way I write Python, and I'm a big Scala fan to begin with - I'm very excited to help on this package however I can :)

kachayev commented 11 years ago

Thanks for implementing this! Commented code in your request.

kachayev commented 11 years ago

Fixed everything at https://github.com/kachayev/fn.py/commit/b510717798b0285584bb068a9855e08f4f63c015 and merged.

danielhfrank commented 11 years ago

Great, thanks for getting it the rest of the way there.