(Fwd) Intervals and numerical orders

Ivan Tomek ivan.tomek at acadiau.ca
Tue Nov 30 19:15:09 UTC 1999


I think that there is some confusion in this discussion what is an 
Interval. In Smalltalk, an Interval is a collection and messages such as 
includes: by convention test for membership - is an object an element 
of the collection? Hence, 1 to: 20 does not include 1.1 because only 1, 
2, 3, ... 20 are the elements of this collection.

In mathematics, intervals mean something else and the mathematical 
meaning requires a different class, not a collection. The name Interval 
for the existing class seems an unfortunate, but already accepted 
choice.

Ivan



------- Forwarded message follows -------
Date forwarded: 	30 Nov 1999 19:04:00 -0000
From:           	Torsten.Bergmann at phaidros.com
To:             	squeak at cs.uiuc.edu
Subject:        	Intervals and numerical orders
Date sent:      	Tue, 30 Nov 1999 20:03:11 +0100
Forwarded by:   	squeak at cs.uiuc.edu
Send reply to:  	squeak at cs.uiuc.edu

Some thought's about the Interval discussion:

Squeak and Smalltalk in general mixes mathematical 
intervals and numerical orders in the Interval class:

If we use

(1 to: 20)   we expect to get an interval with a beginning and
             an end. We can ask this interval if it includes
             a number. It should return true if this number is
   inside the interval. 
   Example: 
   (1 to: 20) includes: 0.9  -> false	
   (1 to: 20) includes: 1    -> true

   (1 to: 20) includes: 1.1  -> true	
   The interval by itself is continuous. [----]
             Maybe we should also think about open intervals with
             infinite beginning or end. [--[
   (1 to: oo) includes: 100 factorial -> true
    oo stands for infinite sign.

(1 to: 20 by: 3) means we want to have a collection of numbers 
       like the following: (1,4,7,...,19).
                 The method Integer>>to:by: should therefore
                 return an array, an instance of a new class
                 called NumericalOrder or whatever. As mathematician 
       we would'nt expect an interval as return value, would
we.

As Smalltalker we would expect an Interval, because we know of
the Integer>>to:by: implementation.

I've asked some non-smalltalkers about that with the result that
people wouldn't expect an interval, because an interval has only a
beginning and an end and is continuous. (They also expect the result
of 3+4*7 as 31 ;)

The only reason for returning an interval is that Smalltalk
can safe a lot of memory if it stores only the beginning, the end and
an increment. So you can easily iterate through a huge collection of
numbers. (1 to: 4000 by: 3) do: [...] 


-Torsten







------- End of forwarded message -------

Dr. Ivan Tomek,
Jodrey School of Computer Science
Acadia University
Nova Scotia, Canada
fax: (902) 585-1067
voice: (902) 585-1467





More information about the Squeak-dev mailing list