Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lazily evaluation like Wu.js with iterator #45

Closed
ankurp opened this issue Jun 19, 2014 · 8 comments
Closed

Add lazily evaluation like Wu.js with iterator #45

ankurp opened this issue Jun 19, 2014 · 8 comments

Comments

@ankurp
Copy link
Owner

ankurp commented Jun 19, 2014

No description provided.

@tsheaff
Copy link
Contributor

tsheaff commented Jun 26, 2014

What kind of interface were you considering? I see a few options.

let squaresIterator = $.lazy_map([1, 2, 3, 4], { $0 * $0 })

Another option is

let squaresIterator = $.Lazy.map([1, 2, 3, 4], { $0 * $0 })

The squaresIterator here would be an instance of Dollar.Iterator, and would hold onto the array and the function and apply it on successive calls to .next() (with helpers .currentIndex, .hasNext etc.) We can then extend Dollar.Iterator to have more helper methods like .toArray() or .each(function)

Thoughts @ankurp ?

@ankurp
Copy link
Owner Author

ankurp commented Jun 26, 2014

$.lazy.map is better options and I agree with creating another class for iterative which hold bunch of other info about the collection like current index etc.

@tsheaff
Copy link
Contributor

tsheaff commented Jun 26, 2014

Cool. I'm gonna implement on my fork and then pull request

@ankurp
Copy link
Owner Author

ankurp commented Jun 26, 2014

Thanks 👍

@ALJCepeda
Copy link

It's done.

@tsheaff
Copy link
Contributor

tsheaff commented Jul 8, 2014

Nice. Yes I dropped the ball on this (busy with other projects), excited to see the result.

@ankurp
Copy link
Owner Author

ankurp commented Oct 23, 2014

Done. Chained expressions are evaluated lazily https://github.com/ankurp/Dollar.swift/blob/master/Dollar/Dollar/Dollar.swift#L269

@ankurp ankurp closed this as completed Oct 23, 2014
@alsotang
Copy link
Contributor

awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants