Email list hosting service & mailing list manager

New release of SRFI 114 with implementation John Cowan (04 Dec 2013 04:16 UTC)
Re: New release of SRFI 114 with implementation Arthur A. Gleckler (04 Dec 2013 05:52 UTC)
Re: New release of SRFI 114 with implementation John Cowan (04 Dec 2013 20:28 UTC)
Re: New release of SRFI 114 with implementation Michael Sperber (04 Dec 2013 08:38 UTC)
Re: New release of SRFI 114 with implementation John Cowan (04 Dec 2013 13:52 UTC)
Re: New release of SRFI 114 with implementation Shiro Kawai (04 Dec 2013 13:54 UTC)
Re: New release of SRFI 114 with implementation John Cowan (04 Dec 2013 20:49 UTC)
Re: New release of SRFI 114 with implementation Shiro Kawai (04 Dec 2013 23:46 UTC)
Re: New release of SRFI 114 with implementation John Cowan (05 Dec 2013 18:35 UTC)
Re: New release of SRFI 114 with implementation Shiro Kawai (05 Dec 2013 22:08 UTC)
Re: New release of SRFI 114 with implementation Kevin Wortman (08 Dec 2013 02:32 UTC)
Re: New release of SRFI 114 with implementation John Cowan (08 Dec 2013 03:13 UTC)
Re: New release of SRFI 114 with implementation Kevin Wortman (08 Dec 2013 03:45 UTC)
Re: New release of SRFI 114 with implementation John Cowan (08 Dec 2013 17:01 UTC)
Re: New release of SRFI 114 with implementation Kevin Wortman (09 Dec 2013 00:10 UTC)
Re: New release of SRFI 114 with implementation John Cowan (09 Dec 2013 00:30 UTC)

Re: New release of SRFI 114 with implementation Kevin Wortman 09 Dec 2013 00:10 UTC

On 12/08/2013 09:01 AM, John Cowan wrote:
> 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.

Gotcha. I was thinking of the algorithm: scan each element and keep
track of the smallest (resp. largest) element you've seen so far.
Something like (untested):

(define (comparator-min comparator first . rest)
  (fold (lambda (x least)
          (if (<? comparator x least) x least))
        first
        rest))

Kevin Wortman