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

Have one-argument '<? et al function as 'make<? et al

This page is part of the web mail archives of SRFI 114 from before July 7th, 2015. The new archives for SRFI 114 contain all messages, not just those from before July 7th, 2015.



Hello SRFI-114 mailing list,

This is a rather SRFI-105-centric proposal, but I'd like to propose
that, if '<? and friends are given a single comparator argument, it
return a function predicate:

 (<? comparator) => predicate-function
 ... and so on...

This allows the following use of SRFI-105:

(define-record-type <set>
  (node c l v r)
  set?
  (c get-c)
  (l get-l)
  (v get-v)
  (r get-r))

{(define set[v-find]
  (cond
    ((null? set) #f)
    ((not (set? set)) (raise-type-error-whatever-whatever))
    (otherwise
      (let ((c (get-c set))
            (v (get-v set)))
        (cond
          ({v-find (<? c) v}  (get-l set)[v-find])
          ({v-find (=? c) v}  #t)
          ({v-find (>? c) v}  (get-r set)[v-find])))))}

Admittedly, it's possible to just use 'make<? and friends if we're
going to use SRFI-105 anyway, but it seems clearer to use <? if
SRFI-105 is something to support.

Sincerely,
AmkG