Re: Intervals representation with brackets
| From: | Rasmus Lerdorf | Date: | Fri, 20 Nov 2009 22:14:53 +0000 |
| Subject: | Re: Intervals representation with brackets | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-46134@lists.php.net to get a copy of this message | ||
Samuel ROZE wrote:
> Hello,
>
> I'm working on two classes, Interval and IntervalList which describe
> an interval and a list of intervals. These intervals are defined using
> the Interval class:
>
> <?php
> $interval = new Interval((int) $from, (int) $to);
> ?>
>
> These intervals can be stored in a list of intervals, using IntervalList:
>
> <?php
> $list = new IntervalList();
> $list->add($interval_1);
> $list->add($interval_2);
> ?>
>
> IntervalList's functions are:
> - inverse(); which returns an IntervalList object
> - intersection(); which returns an IntervalList object of intervals
> which are contained by every interval of this list.
>
> To be easier, what do you think about:
> <?php
> // An interval with [ & ]
> $interval = [ (int) $from, (int) $to ];
> ?>
>
> <?php
> // A list of intervals
> $list = [ $from_1, $to_1] + [$from_2, $to_2] + ... [$from_n, $to_n];
> $list_2 = [$from_1, $to_1] + ... + $interval_n;
> ?>
No chance that top-level square brackets will mean intervals, sorry.
-Rasmus