[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New release of SRFI 114 with implementation



Kevin Wortman scripsit:

> Returning the first tied argument seems like it would be a little more
> straightforward to implement, at least to me. But I'm comfortable with
> the current behavior. I don't think it matters much as long as the
> behavior is documented.

Here's the current sample implementation (note that it depends on `apply`
calling its argument tail-recursively):

(define comparator-min
  (case-lambda
    ((comparator a)
      a)
    ((comparator a b)
     (if (<? comparator a b) a b))
    ((comparator a b . objs)
     (comparator-min comparator a (apply comparator-min comparator b objs)))))

(define comparator-max
  (case-lambda
    ((comparator a)
      a)
    ((comparator a b)
     (if (>? comparator a b) a b))
    ((comparator a b . objs)
     (comparator-max comparator a (apply comparator-max comparator b objs)))))

Exactly what you get depends on which predicate you use, of course.

-- 
John Cowan    http://ccil.org/~cowan    cowan@xxxxxxxx
[T]here is a Darwinian explanation for the refusal to accept Darwin.
Given the very pessimistic conclusions about moral purpose to which his
theory drives us, and given the importance of a sense of moral purpose
in helping us cope with life, a refusal to believe Darwin's theory may
have important survival value. --Ian Johnston