Changeset 8626 in project


Ignore:
Timestamp:
02/21/08 21:35:18 (12 years ago)
Author:
Kon Lovett
Message:

Renames to match doc. Where is 'span'?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/combinators/trunk/combinators-support.scm

    r8624 r8626  
    1313    (inline)
    1414    (no-procedure-checks-for-usual-bindings)
    15     (no-bound-checks) ) )
     15    (no-bound-checks)
     16    (import
     17      span ) ) )
    1618   
    1719;; Group a list of elements by some key attribute.
     
    2224;; (group-by car '((a 1) (a 2) (b 1))) --> '(((a 1) (a 2)) ((b 1)))
    2325
    24 (define (group-by keyproc lst #!optional (is-equal equal?))
     26(define (group-by keyproc lst #!optional (equality equal?))
    2527  (let loop ((lst lst) (acc '()))
    2628    (if (null? lst)
     
    2830        (let ((key (keyproc (car lst))))
    2931          (receive (grouped rest)
    30               (span (lambda (item) (is-equal key (keyproc item))) lst)
     32              (span (lambda (item) (equality key (keyproc item))) lst)
    3133            (loop rest (cons grouped acc)))))))
    3234
    33 ;; Define a comparator function for a sort. E.g. to sort a list of
     35;; Define a less-than function for a sort. E.g. to sort a list of
    3436;; lists by their first items, using string-case-insensitive
    3537;; comparison: (sort lst (key-on first string-ci<?))
    3638
    37 (define (key-on proc #!optional (comparator <))
    38   (lambda (a b) (comparator (proc a) (proc b))))
     39(define (key-on keyproc #!optional (less-than <))
     40  (lambda (a b) (less-than (keyproc a) (keyproc b))))
Note: See TracChangeset for help on using the changeset viewer.