You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Bruno P. Kinoshita" <ki...@apache.org> on 2013/08/24 18:52:38 UTC
[functor][FUNCTOR-14] Merge generators branch
Hi All,
I would like to merge [functor]'s branch generators-FUNCTOR-14 [1], related to issue FUNCTOR-14 [2].
This the summary of the changes in that branch:
- New subpackage, o.a.c.functor.generator.loop
- New generator type added, LoopGenerator, that can be stopped
- The BaseGenerator has no long isStopped() or stop() methods. Both have been moved to the LoopGenerator.
- Ranges are no long generators
- New package o.a.c.functor.range
- Range extends Iterable and Iterator interfaces
The motivation for these changes were to be able to create generators that didn't have the stoppable behaviour (thus the new package and type), and to be able to have simple ranges in for loops.
Before the new range package, in order to iterate over the created range, you would have to write a Procedure that would be used as a callback for each range element. Now, by extending Iterable/Iterator you can do as follows:
+--snippet--+
Range<Integer, Integer> n = new IntegerRange(0, 10);
for (int i : n) {
System.out.printf("%d ", i);
}
+--snippet--+
That produces 0 1 2 3 4 5 6 7 8 9 , or even a range like:
+--snippet--+
for (int i : Ranges.integerRange(0, BoundType.OPEN, 10, BoundType.OPEN, 2)) { // 2 is the step
System.out.printf("%d ", i);
}
+--snippet--+
That produces 2 4 6 8 .
Any thoughts/objections on this?
Thank you in advance!
[1] http://svn.apache.org/repos/asf/commons/proper/functor/branches/generators-FUNCTOR-14/
[2] https://issues.apache.org/jira/browse/FUNCTOR-14
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [functor][FUNCTOR-14] Merge generators branch
Posted by Benedikt Ritter <br...@apache.org>.
2013/8/29 Bruno P. Kinoshita <br...@yahoo.com.br>
> Hi Benedikt,
>
> >From just looking at this code snipped I don't get what BoundType.OPEN
> >means. Can you enlighten me? ;-)
>
> The BoundType.{OPEN|CLOSED} is used to control whether the left and right
> boundary values are included in the range. i.e.,
>
> 0, OPEN, 2, OPEN = (0, 2)
> 0, CLOSED, 2, OPEN = (0, 2]
>
> After merging the branch I want to write a documentation web page for the
> Ranges
> API in [functor]. Hopefully that will help users to understand what that
> means too.
>
> Does that help?
>
Yes makes sense now :-) Thanks!
>
> Thanks for looking into it :)
>
> Bruno P. Kinoshita
> http://kinoshita.eti.br
> http://tupilabs.com
>
>
>
> >________________________________
> > From: Benedikt Ritter <br...@apache.org>
> >To: Commons Developers List <de...@commons.apache.org>
> >Sent: Thursday, August 29, 2013 4:57 AM
> >Subject: Re: [functor][FUNCTOR-14] Merge generators branch
> >
> >
> >Hi Bruno,
> >
> >
> >2013/8/24 Bruno P. Kinoshita <ki...@apache.org>
> >
> >> Hi All,
> >>
> >> I would like to merge [functor]'s branch generators-FUNCTOR-14 [1],
> >> related to issue FUNCTOR-14 [2].
> >>
> >> This the summary of the changes in that branch:
> >>
> >> - New subpackage, o.a.c.functor.generator.loop
> >> - New generator type added, LoopGenerator, that can be stopped
> >> - The BaseGenerator has no long isStopped() or stop() methods. Both have
> >> been moved to the LoopGenerator.
> >> - Ranges are no long generators
> >> - New package o.a.c.functor.range
> >> - Range extends Iterable and Iterator interfaces
> >>
> >> The motivation for these changes were to be able to create generators
> that
> >> didn't have the stoppable behaviour (thus the new package and type),
> and to
> >> be able to have simple ranges in for loops.
> >>
> >> Before the new range package, in order to iterate over the created
> range,
> >> you would have to write a Procedure that would be used as a callback for
> >> each range element. Now, by extending Iterable/Iterator you can do as
> >> follows:
> >>
> >> +--snippet--+
> >> Range<Integer, Integer> n = new IntegerRange(0, 10);
> >> for (int i : n) {
> >> System.out.printf("%d ", i);
> >> }
> >> +--snippet--+
> >>
> >>
> >> That produces 0 1 2 3 4 5 6 7 8 9 , or even a range like:
> >>
> >> +--snippet--+
> >>
> >> for (int i : Ranges.integerRange(0, BoundType.OPEN, 10, BoundType.OPEN,
> >> 2)) { // 2 is the step
> >> System.out.printf("%d ", i);
> >> }
> >> +--snippet--+
> >>
> >
> >From just looking at this code snipped I don't get what BoundType.OPEN
> >means. Can you enlighten me? ;-)
> >
> >Benedikt
> >
> >
> >>
> >> That produces 2 4 6 8 .
> >>
> >> Any thoughts/objections on this?
> >>
> >> Thank you in advance!
> >>
> >> [1]
> >>
> http://svn.apache.org/repos/asf/commons/proper/functor/branches/generators-FUNCTOR-14/
> >> [2] https://issues.apache.org/jira/browse/FUNCTOR-14
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> >> For additional commands, e-mail: dev-help@commons.apache.org
> >>
> >>
> >
> >
> >--
> >http://people.apache.org/~britter/
> >http://www.systemoutprintln.de/
> >http://twitter.com/BenediktRitter
> >http://github.com/britter
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter
Re: [functor][FUNCTOR-14] Merge generators branch
Posted by "Bruno P. Kinoshita" <br...@yahoo.com.br>.
Hi Benedikt,
>From just looking at this code snipped I don't get what BoundType.OPEN
>means. Can you enlighten me? ;-)
The BoundType.{OPEN|CLOSED} is used to control whether the left and right
boundary values are included in the range. i.e.,
0, OPEN, 2, OPEN = (0, 2)
0, CLOSED, 2, OPEN = (0, 2]
After merging the branch I want to write a documentation web page for the Ranges
API in [functor]. Hopefully that will help users to understand what that means too.
Does that help?
Thanks for looking into it :)
Bruno P. Kinoshita
http://kinoshita.eti.br
http://tupilabs.com
>________________________________
> From: Benedikt Ritter <br...@apache.org>
>To: Commons Developers List <de...@commons.apache.org>
>Sent: Thursday, August 29, 2013 4:57 AM
>Subject: Re: [functor][FUNCTOR-14] Merge generators branch
>
>
>Hi Bruno,
>
>
>2013/8/24 Bruno P. Kinoshita <ki...@apache.org>
>
>> Hi All,
>>
>> I would like to merge [functor]'s branch generators-FUNCTOR-14 [1],
>> related to issue FUNCTOR-14 [2].
>>
>> This the summary of the changes in that branch:
>>
>> - New subpackage, o.a.c.functor.generator.loop
>> - New generator type added, LoopGenerator, that can be stopped
>> - The BaseGenerator has no long isStopped() or stop() methods. Both have
>> been moved to the LoopGenerator.
>> - Ranges are no long generators
>> - New package o.a.c.functor.range
>> - Range extends Iterable and Iterator interfaces
>>
>> The motivation for these changes were to be able to create generators that
>> didn't have the stoppable behaviour (thus the new package and type), and to
>> be able to have simple ranges in for loops.
>>
>> Before the new range package, in order to iterate over the created range,
>> you would have to write a Procedure that would be used as a callback for
>> each range element. Now, by extending Iterable/Iterator you can do as
>> follows:
>>
>> +--snippet--+
>> Range<Integer, Integer> n = new IntegerRange(0, 10);
>> for (int i : n) {
>> System.out.printf("%d ", i);
>> }
>> +--snippet--+
>>
>>
>> That produces 0 1 2 3 4 5 6 7 8 9 , or even a range like:
>>
>> +--snippet--+
>>
>> for (int i : Ranges.integerRange(0, BoundType.OPEN, 10, BoundType.OPEN,
>> 2)) { // 2 is the step
>> System.out.printf("%d ", i);
>> }
>> +--snippet--+
>>
>
>From just looking at this code snipped I don't get what BoundType.OPEN
>means. Can you enlighten me? ;-)
>
>Benedikt
>
>
>>
>> That produces 2 4 6 8 .
>>
>> Any thoughts/objections on this?
>>
>> Thank you in advance!
>>
>> [1]
>> http://svn.apache.org/repos/asf/commons/proper/functor/branches/generators-FUNCTOR-14/
>> [2] https://issues.apache.org/jira/browse/FUNCTOR-14
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
>
>--
>http://people.apache.org/~britter/
>http://www.systemoutprintln.de/
>http://twitter.com/BenediktRitter
>http://github.com/britter
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [functor][FUNCTOR-14] Merge generators branch
Posted by Benedikt Ritter <br...@apache.org>.
Hi Bruno,
2013/8/24 Bruno P. Kinoshita <ki...@apache.org>
> Hi All,
>
> I would like to merge [functor]'s branch generators-FUNCTOR-14 [1],
> related to issue FUNCTOR-14 [2].
>
> This the summary of the changes in that branch:
>
> - New subpackage, o.a.c.functor.generator.loop
> - New generator type added, LoopGenerator, that can be stopped
> - The BaseGenerator has no long isStopped() or stop() methods. Both have
> been moved to the LoopGenerator.
> - Ranges are no long generators
> - New package o.a.c.functor.range
> - Range extends Iterable and Iterator interfaces
>
> The motivation for these changes were to be able to create generators that
> didn't have the stoppable behaviour (thus the new package and type), and to
> be able to have simple ranges in for loops.
>
> Before the new range package, in order to iterate over the created range,
> you would have to write a Procedure that would be used as a callback for
> each range element. Now, by extending Iterable/Iterator you can do as
> follows:
>
> +--snippet--+
> Range<Integer, Integer> n = new IntegerRange(0, 10);
> for (int i : n) {
> System.out.printf("%d ", i);
> }
> +--snippet--+
>
>
> That produces 0 1 2 3 4 5 6 7 8 9 , or even a range like:
>
> +--snippet--+
>
> for (int i : Ranges.integerRange(0, BoundType.OPEN, 10, BoundType.OPEN,
> 2)) { // 2 is the step
> System.out.printf("%d ", i);
> }
> +--snippet--+
>
>From just looking at this code snipped I don't get what BoundType.OPEN
means. Can you enlighten me? ;-)
Benedikt
>
> That produces 2 4 6 8 .
>
> Any thoughts/objections on this?
>
> Thank you in advance!
>
> [1]
> http://svn.apache.org/repos/asf/commons/proper/functor/branches/generators-FUNCTOR-14/
> [2] https://issues.apache.org/jira/browse/FUNCTOR-14
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
--
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter