Changeset 16017 in project


Ignore:
Timestamp:
09/21/09 18:29:18 (10 years ago)
Author:
Kon Lovett
Message:

Save.

Location:
release/4/srfi-19
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/srfi-19/tags/3.0.0/chicken-primitive-object-inlines.scm

    r15792 r16017  
    712712        (loop (%cdr ls) (%fxsub1 n)) ) ) )
    713713
    714 (define-inline (%any/1 pred? ls)
     714(define-inline (%list-any/1 pred? ls)
    715715  (let loop ((ls ls))
    716716    (and (not (%null? ls))
     
    718718             (loop (%cdr ls)) ) ) ) )
    719719
     720(define-inline (%list-every/1 pred? ls)
     721  (let loop ((ls ls))
     722    (or (%null? ls)
     723        (and (pred? (%car ls))
     724             (loop (%cdr ls))) ) ) )
     725
    720726(define-inline (%list-length ls0)
    721727  (let loop ((ls ls0) (n 0))
    722728    (if (%null? ls) n
    723729        (loop (%cdr ls) (%fxadd1 n)) ) ) )
     730
     731(define-inline (%list-find pred? ls)
     732  (let loop ((ls ls))
     733    (and (not (%null? ls))
     734         (or (let ((elm (%car ls))) (and (pred? elm) elm))
     735             (loop (%cdr ls)) ) ) ) )
     736
     737(define-inline (%alist-ref key al #!optional (test eqv?) def)
     738  (let loop ((al al))
     739    (cond ((%null? al) def )
     740          ((test key (%caar al)) (%cdar al) )
     741          (else (loop (%cdr al)) ) ) ) )
     742
     743(define-inline (%alist-update! key val al0 #!optional (test eqv?))
     744  (let loop ((al al0))
     745    (cond ((%null? al) (%cons (%cons key val) al0) )
     746          ((test key (%caar al)) (%set-cdr! (%car al) val) al0 )
     747          (else (loop (%cdr al)) ) ) ) )
     748
     749(define-inline (%alist-delete! key al0 #!optional (test equal?))
     750  (let loop ((al al0) (prv #f))
     751    (cond ((%null? al) al0)
     752          ((test key (%caar al)) (if prv (begin (%set-cdr! prv (%cdr al)) al0) (%cdr al)) )
     753          (else (loop (%cdr al) al) ) ) ) )
    724754
    725755;; Structure (wordblock)
  • release/4/srfi-19/trunk/chicken-primitive-object-inlines.scm

    r15792 r16017  
    712712        (loop (%cdr ls) (%fxsub1 n)) ) ) )
    713713
    714 (define-inline (%any/1 pred? ls)
     714(define-inline (%list-any/1 pred? ls)
    715715  (let loop ((ls ls))
    716716    (and (not (%null? ls))
     
    718718             (loop (%cdr ls)) ) ) ) )
    719719
     720(define-inline (%list-every/1 pred? ls)
     721  (let loop ((ls ls))
     722    (or (%null? ls)
     723        (and (pred? (%car ls))
     724             (loop (%cdr ls))) ) ) )
     725
    720726(define-inline (%list-length ls0)
    721727  (let loop ((ls ls0) (n 0))
    722728    (if (%null? ls) n
    723729        (loop (%cdr ls) (%fxadd1 n)) ) ) )
     730
     731(define-inline (%list-find pred? ls)
     732  (let loop ((ls ls))
     733    (and (not (%null? ls))
     734         (or (let ((elm (%car ls))) (and (pred? elm) elm))
     735             (loop (%cdr ls)) ) ) ) )
     736
     737(define-inline (%alist-ref key al #!optional (test eqv?) def)
     738  (let loop ((al al))
     739    (cond ((%null? al) def )
     740          ((test key (%caar al)) (%cdar al) )
     741          (else (loop (%cdr al)) ) ) ) )
     742
     743(define-inline (%alist-update! key val al0 #!optional (test eqv?))
     744  (let loop ((al al0))
     745    (cond ((%null? al) (%cons (%cons key val) al0) )
     746          ((test key (%caar al)) (%set-cdr! (%car al) val) al0 )
     747          (else (loop (%cdr al)) ) ) ) )
     748
     749(define-inline (%alist-delete! key al0 #!optional (test equal?))
     750  (let loop ((al al0) (prv #f))
     751    (cond ((%null? al) al0)
     752          ((test key (%caar al)) (if prv (begin (%set-cdr! prv (%cdr al)) al0) (%cdr al)) )
     753          (else (loop (%cdr al) al) ) ) ) )
    724754
    725755;; Structure (wordblock)
Note: See TracChangeset for help on using the changeset viewer.