between and among: worth Phobosization?

Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com> Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com>
Wed Dec 18 00:58:02 PST 2013


On Wednesday, 18 December 2013 at 02:17:06 UTC, Andrei 
Alexandrescu wrote:
> On 12/17/13 5:58 PM, "Ola Fosheim Grøstad" 
> <ola.fosheim.grostad+dlang at gmail.com>" wrote:
>> Why is that? I would think that 10 == Interval(10,10), but
>> interval(5,100).contains(10) ?
>
> Yah, defining == my way would make it non-transitive.
>
>> True interval arithmetic is difficult to
>> implement though, since !(a<b) does not imply (a>=b) if I got 
>> it right…
>
> I didn't peruse the wikipedia page in detail but it seems a lot 
> of interval arithmetic is well-defined.

But it is counter-intuitive since an interval represent 
uncertainty?

[5,5] == [5,5] => true
[1,5] != [1,5]  => false? // counter-intuitive
[0,5] < [6,10] => true
[0,5] < [2,10] => uncertain

>> So you you might have to introduce a tri-boolean type
>
> That would be good too for distinct reasons.

I wrote libraries for both tribool and fuzzybool for D 7 years 
ago to see how D worked for ADTs. I guess I could rewrite those 
to be more modern and make it available as a starting point. I 
believe I also started on (or planned) to do fuzzy numbers. Fuzzy 
numbers are related to intervals, but have a triangular 
membership function. You use it for representing hazy values like 
"pretty" or "intelligent" (the same person can be both smart and 
stupid at the same time). There are more than one definition, 
each with trade-offs.

e.g.:
fast = FuzzyNumber(40,60,70)
slow = FuzzyNumber(1,10,40)

However, one deficiency in D is (or was) that you cannot make 
comparison operators return non-bool values?

Anyway, I think it might be a good idea to implement Intervals, 
Fuzzynumber, Tribool and Fuzzylogic in a manner that is 
consistent.


More information about the Digitalmars-d mailing list