Changeset 34649 in project


Ignore:
Timestamp:
09/29/17 06:30:13 (3 weeks ago)
Author:
kon
Message:

r7rs

Location:
release/4/list-utils/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/list-utils/trunk/list-utils.scm

    r34410 r34649  
    2121  assv-def
    2222  alist-inverse-ref
    23   alist-delete/count
    24   alist-delete!/count
     23  alist-delete-for-count
     24  alist-delete-for-count!
    2525  plist->alist
    2626  alist->plist
     
    3131  shift!/set
    3232  andmap
    33   ormap)
     33  ormap
     34  ;DEPRECATED
     35  alist-delete/count
     36  alist-delete!/count)
    3437
    3538(import scheme chicken)
     
    188191      (alist-delete-first ?key ?als eqv?) )
    189192                ((_ ?key ?als ?=)
    190       (alist-delete/count ?key ?als ?= 1) ) ) )
     193      (alist-delete-for-count ?key ?als ?= 1) ) ) )
    191194
    192195;; Remove 1st matching elements from the alist (destructive)
     
    197200      (alist-delete-first ?key ?als eqv?) )
    198201                ((_ ?key ?als ?=)
    199       (alist-delete!/count ?key ?als ?= 1) ) ) )
     202      (alist-delete-for-count! ?key ?als ?= 1) ) ) )
    200203
    201204;; Some alist search macros.
     
    287290;; Remove 1st N matching elements from the alist (functional)
    288291
    289 (define (alist-delete/count key al #!optional (cmp eqv?) (cnt most-positive-fixnum))
    290   (*alist-delete/count 'alist-delete/count key al cmp cnt) )
    291 
    292 (define (*alist-delete/count loc key al cmp cnt)
     292(define (alist-delete-for-count key al #!optional (cmp eqv?) (cnt most-positive-fixnum))
     293  (*alist-delete-for-count 'alist-delete-for-count key al cmp cnt) )
     294
     295(define (*alist-delete-for-count loc key al cmp cnt)
    293296  (check-procedure loc cmp)
    294297  (let loop ((cal (check-list loc al)) (cnt (check-fixnum loc cnt)) (oal '()))
     
    313316;; Remove 1st N matching elements from the alist (destructive)
    314317
    315 (define (alist-delete!/count key al #!optional (cmp eqv?) (cnt most-positive-fixnum))
    316   (*alist-delete!/count 'alist-delete!/count key al cmp cnt) )
    317 
    318 (define (*alist-delete!/count loc key al cmp cnt)
     318(define (alist-delete-for-count! key al #!optional (cmp eqv?) (cnt most-positive-fixnum))
     319  (*alist-delete-for-count! 'alist-delete-for-count! key al cmp cnt) )
     320
     321(define (*alist-delete-for-count! loc key al cmp cnt)
    319322  (check-procedure loc cmp)
    320323  (let ((ral (check-list loc al)))
     
    444447          (loop (cdr ls) (fx- n 1) (cons (car ls) part)) ) ) ) ) )
    445448
     449;;;DEPRECATED
     450
     451(define alist-delete/count alist-delete-for-count)
     452(define alist-delete!/count alist-delete-for-count!)
     453
    446454) ;module list-utils
  • release/4/list-utils/trunk/list-utils.setup

    r34410 r34649  
    55(verify-extension-name "list-utils")
    66
    7 (setup-shared-extension-module 'list-utils (extension-version "1.1.3")
     7(setup-shared-extension-module 'list-utils (extension-version "1.2.0")
    88  #:inline? #t
    99  #:types? #t
  • release/4/list-utils/trunk/tests/run.scm

    r28408 r34649  
    118118)
    119119
     120#; ;
    120121(test-group  "Alist Delete"
    121122  (test '((a 1) (c 4) (b 5) (a 6) (d 7)) (alist-delete/count 'b alst1 eq? 2))
     
    132133)
    133134
     135(test-group  "Alist Delete"
     136  (test '((a 1) (c 4) (b 5) (a 6) (d 7)) (alist-delete-for-count 'b alst1 eq? 2))
     137  (test '((a 1) (c 4) (a 6) (d 7)) (alist-delete-for-count 'b alst1 eq?))
     138  (test '((a 1) (b 2) (b 3) (c 4) (b 5) (a 6)) (alist-delete-for-count 'd alst1 eq?))
     139  (test '((a 1) (b 2) (b 3) (b 5) (a 6) (d 7)) (alist-delete-for-count 'c alst1 eq?))
     140  (test '((b 2) (b 3) (c 4) (b 5) (a 6) (d 7)) (alist-delete-for-count 'a alst1 eq? 1))
     141
     142  (test '((a 1) (c 4) (b 5) (a 6) (d 7)) (alist-delete-for-count! 'b alst1 eq? 2))
     143  (test '((a 1) (c 4) (a 6) (d 7)) (alist-delete-for-count! 'b alst1 eq?))
     144  (test '((a 1) (c 4) (a 6)) (alist-delete-for-count! 'd alst1 eq?))
     145  (test '((a 1) (a 6)) (alist-delete-for-count! 'c alst1 eq?))
     146  (test '((a 6)) (alist-delete-for-count! 'a alst1 eq? 1))
     147)
     148
    134149(test-exit)
Note: See TracChangeset for help on using the changeset viewer.