# Intervals representation with brackets

- Thread: https://externals.io/message/46131
- Original archive: https://news-web.php.net/php.internals/46131
- Started by Samuel ROZE on 2009-11-20T21:56:54+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #46131 — Samuel ROZE — 2009-11-20T21:56:54+00:00

URL: https://externals.io/message/46131#46131

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;
?>

Regards,
Samuel ROZE.

---

## #46132 — Hannes Magnusson — 2009-11-20T22:06:27+00:00

URL: https://externals.io/message/46131#46132 · In reply to: #46131

[...]
> <?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;
> ?>

This made no sense to me.

Are you suggesting new object operator? Short-syntax-array?
What exactly are you asking/informing/reporting/whatever?

-Hannes

---

## #46133 — mm w — 2009-11-20T22:07:54+00:00

URL: https://externals.io/message/46131#46133 · In reply to: #46131

http://code.google.com/p/foundation-kit/source/browse/trunk/FKRange.php
http://code.google.com/p/foundation-kit/source/browse/trunk/FKIndexSet.php


> 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;
> ?>
>
> Regards,
> Samuel ROZE.

---

## #46134 — Rasmus Lerdorf — 2009-11-20T22:14:53+00:00

URL: https://externals.io/message/46131#46134 · In reply to: #46131

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

---

## #46135 — Samuel ROZE — 2009-11-20T22:20:53+00:00

URL: https://externals.io/message/46131#46135 · In reply to: #46132

> Are you suggesting new object operator? Short-syntax-array?

Short-syntax-interval ! :-)

> What exactly are you asking/informing/reporting/whatever?

I'm just asking if, for you, brackets can represent intervals...

---

## #46136 — Samuel ROZE — 2009-11-20T22:21:24+00:00

URL: https://externals.io/message/46131#46136 · In reply to: #46134

It's clear. ;-)
Thanks.

2009/11/20 Rasmus Lerdorf <rasmus@lerdorf.com>:
> Samuel ROZE wrote:
> > […]
>
> No chance that top-level square brackets will mean intervals, sorry.
>
> -Rasmus

---

## #46137 — Samuel ROZE — 2009-11-20T22:22:34+00:00

URL: https://externals.io/message/46131#46137 · In reply to: #46133

Hi,

This isn't bad, but it's not really what i want, and... what I wrote! ;-)

Samuel.

2009/11/20 mm w <0xcafefeed@gmail.com>:
> http://code.google.com/p/foundation-kit/source/browse/trunk/FKRange.php
> http://code.google.com/p/foundation-kit/source/browse/trunk/FKIndexSet.php
>
> 
> > […]

---

## #46138 — mm w — 2009-11-20T22:36:07+00:00

URL: https://externals.io/message/46131#46138 · In reply to: #46137

Hello,

Even if you are introducing a new syntax, your approach is wrong to
get intersection and interval, I was not talkative
but the samples I gave you expose several cases

// This isn't bad, but it's not really what i want, and... what I wrote! ;-)

so I guess you don't even understand what your are doing ? playing
with range, you may read the documentation about those objects into
the Apple Foundation those are following the same model, dealing with
list of ranges.

anyway what you exposed was really unclear, try to be more didactic,
we don't have crystal balls, and somehow Ijust trolled you like you
did, so please we are people we need a context.

Best,


> Hi,
>
> This isn't bad, but it's not really what i want, and... what I wrote! ;-)
>
> Samuel.
>
> 2009/11/20 mm w <0xcafefeed@gmail.com>:
> > […]
