Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-25 Thread cy via Digitalmars-d
template emit(T, alias fun) I wonder if "template emit(alias fun, T)" wouldn't be a better idea. That way you could leave T open for type inference, even if you specify a function. D doesn't support reordering template arguments, so it's important to put the ones "most used" at the

Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-24 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 23 March 2016 at 17:43:07 UTC, Tamas wrote: On Wednesday, 23 March 2016 at 17:29:55 UTC, Nick Treleaven wrote: On Monday, 21 March 2016 at 23:09:27 UTC, Tamas wrote: On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote: Could you try to point out whats wrong with map & filter?

Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-23 Thread thedeemon via Digitalmars-d
On Monday, 21 March 2016 at 23:09:27 UTC, Tamas wrote: On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote: Could you try to point out whats wrong with map & filter? It's hard to do stuff like this: assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a); if(a%3==0)

Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-23 Thread crimaniak via Digitalmars-d
On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote: On Monday, 21 March 2016 at 11:35:49 UTC, Timothee Cour wrote: assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a);}).equal([1, 9, 25, 49])) I support idea to have such feature, sometimes it really need. Could you try to point out whats

Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-23 Thread Tamas via Digitalmars-d
On Wednesday, 23 March 2016 at 17:29:55 UTC, Nick Treleaven wrote: On Monday, 21 March 2016 at 23:09:27 UTC, Tamas wrote: On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote: Could you try to point out whats wrong with map & filter? It's hard to do stuff like this:

Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-23 Thread Nick Treleaven via Digitalmars-d
On Monday, 21 March 2016 at 23:09:27 UTC, Tamas wrote: On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote: Could you try to point out whats wrong with map & filter? It's hard to do stuff like this: assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a); if(a%3==0)

Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-21 Thread Tamas via Digitalmars-d
On Monday, 21 March 2016 at 11:48:52 UTC, Seb wrote: Could you try to point out whats wrong with map & filter? It's hard to do stuff like this: assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a); if(a%3==0) put(a);}).equal([1,9,3,25,6,49]));

Re: emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-21 Thread Seb via Digitalmars-d
On Monday, 21 March 2016 at 11:35:49 UTC, Timothee Cour wrote: assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a);}).equal([1, 9, 25, 49])) Could you try to point out whats wrong with map & filter? assert(9.iota.filter!"a%2".map!"a*a".equal([1, 9, 25, 49])

emit: generalizes map, filter, joiner [proposal + implementation]

2016-03-21 Thread Timothee Cour via Digitalmars-d
given fun(put, a) a lambda that can call $put 0 or more times, some_range.emit!fun computes a range formed of all the calls to $put eg: assert(9.iota.emit!(int,(put,a){if(a%2) put(a*a);}).equal([1, 9, 25, 49])); in this case it can be done by combining map and filter but in other cases emit is