[r6rs-discuss] Comparison procedures' number of arguments
Thomas Lord
lord at emf.net
Tue Oct 21 17:57:19 EDT 2008
Ken Dickey wrote:
> Well if I write it... ;^)
>
> (define <?
> (lambda list-of-numbers
> (assert (list? list-of-numbers))
> (assert (for-all number? list-of-numbers))
> (monotonic? < list-of-numbers)
> ) )
>
> (define char-<? ...)
I'm looking for:
(define <? (raise-for-sequences <))
but I only see how to write:
(define <? (raise-for-sequences < number?))
The implementation already "knows" in some sense
that number? is the type to use here but I have to tell
it so anyway. There's some kind of reflective capability
that's "missing" in Scheme.
Ok, I can do the singleton case by comparing the sole
element to itself (and ignoring the result but doing the
type check) but that seems Wrong.
> Quibble: In Scheme, "<" is the name of a function.
>
> A "relation on a pair" implies that there must be a pair to be a relation.
>
>
> When I look up "binary relation" in Wikipedia I find:
>
> The statement (x,y) ∈ R is read "x is R-related to y", and is denoted by xRy
> or R(x,y). The latter notation corresponds to viewing R as the characteristic
> function of the _set of pairs_ G. [emphasis mine]
>
> There is no mention of a binary relation on non-pairs.
>
You can look up wikipedia on "relation".
It'll tell you that a /k/-relation is the characteristic function of a
particular set of /k/-tuples.
Thus, Scheme's current < doesn't behave like a /k/-relation for any
value of /k/.
>
> If I look up "well ordered" I find:
>
> In mathematics, a well-order relation (or well-ordering) on a set S is a total
> order on S with the property that every _non-empty subset_ of S has a least
> element in this ordering. Equivalently, a well-ordering is a well-founded
> total order. The set S together with the well-order relation is then called a
> well-ordered set.
>
> Every element, except a possible greatest element, has a unique successor
> (next element).
>
Vocabulary confusion (sorry for causing it). We can pick a different word.
How about "sorted"? The empty list is sorted. All singleton lists
are sorted.
Etc.
>
> I.e. the null sequence/set is explicitly excluded.
My bad. The "well ordered" you found in wikipedia is a property
of a relation on a set. I should have said "sorted" to refer to a
property of sequences.
> Given that S must be
> ordered, it follows from the (binary) order relation such a set must have at
> least two elements to relate [my reading].
>
A fine example of why I do not claim to be a good teacher
because by saying "well ordererd" when I meant "sorted"
(or "monotonic") I sent you off on a confusing goose chase.
>
>
>> Std definition => "a singleton or empty list is well ordered"
>> Ken's definition => "a singleton or empty list is neither well
>> ordered or not ordered"
>>
>
> should read:
> Ken's definition => "a singleton or empty list is _not_ ordered".
>
And you should be saying "monotonic" or "sorted" as well.
-t
More information about the r6rs-discuss
mailing list