Thomas Lord scripsit:

> A piece of equipment takes some number of measurements in a given period
> of time, T.  The numeric values of the measurements should be monotonic.
> The number of measurements during T is greater than or equal to 0.
> If they are not monotonic, the procedure EMERGENCY-HALT-ENGINE should
> be called.
> 
> That's a case when it is *natural* to want arbitrary-arity comparison
> functions.

I don't think so.  Such a machine has two pieces of state: the last
measurement taken, and a four-way state indicator: virgin, level,
increasing, decreasing.  (It also needs a clock to determine when T
is over.) When each measurement arrives, the following expression is
evaluated for effect:

(begin
  (cond ((eq? state 'virgin)
         (set! state 'level))
        ((and (eq? state 'level) (> current last))
         (set! state 'increasing))
        ((and (eq? state 'level) (< current last))
         (set! state decreasing))
        ((and (eq? state 'increasing) (< current last))
         (emergency-halt-engine))
        ((and (eq? state 'decreasing) (> current last))
         (emergency-halt-engine)))
  (set! last current))

Even if all the measurements are available simultaneously (how?), none
of the Scheme numeric comparison functions will return the correct results.
The function you will need to apply to those measurements will still look
very much like the above.

> Commonly we assemble equipment that takes 0 or more measurements in
> a given T where we have some predictate P, that accepts 0 or more
> measurements and returns #t iff we should call EMERGENCY-HALT-ENGINE.
> Useful predicates include "all the measurements have a sum which is
> non-negative" and "all of the measurements are prime numbers".

Neither of these is anything like an ordering predicate.

> That's a whole family of cases of which the more flexible arity versions
> of ordering predicates are useful.

Again, I don't see how.  Your first case requires just one piece of state,
the running sum; your second case is stateless.

> In general, deciding that an ordering predicate "expects" two or
> more arguments expresses an expectation that is kind of arbitrary
> relative to the simplest accounts of the underlying domains.   It is an
> "arbitrary restriction,"

The fact there's no dispute about the meaning of more than one argument,
whereas the interpretations of zero and one arguments are all over the
lot, suggests that the restriction is anything but arbitrary.  The true
underlying domain, I think, is not numbers but ordering itself (there
is no reason why these functions could not be polymorphic, as they are in
many other languages), and in a domain where there exist (timelessly)
only one item, or zero items, ordering simply doesn't apply.

-- 
John Cowan    http://ccil.org/~cowan    [EMAIL PROTECTED]
Mr. Henry James writes fiction as if it were a painful duty.  --Oscar Wilde

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to