Ticket #1174: srfi-42-append-ec.patch

File srfi-42-append-ec.patch, 1.1 KB (added by acharlton, 10 years ago)
  • srfi-42.scm

    diff -du srfi-42/srfi-42.scm srfi-42-new/srfi-42.scm
    old new  
    3333
    3434(module srfi-42
    3535
    36         ( do-ec list-ec append-ec string-ec
     36        ( do-ec list-ec (append-ec append*) string-ec
    3737          string-append-ec vector-ec vector-of-length-ec
    3838          sum-ec product-ec min-ec max-ec any?-ec
    3939          every?-ec first-ec last-ec fold-ec fold3-ec
     
    892892(define-syntax append-ec
    893893  (syntax-rules ()
    894894    ((append-ec etc1 etc ...)
    895      (apply append (list-ec etc1 etc ...)) )))
     895     (append* (list-ec etc1 etc ...)) )))
     896
     897;; Copied from srfi-1, changed to accept only one argument:
     898(define (append* lists)
     899  (if (pair? lists)
     900      (let recur ((list1 (car lists)) (lists (cdr lists)))
     901        (if (pair? lists)
     902            (let ((tail (recur (car lists) (cdr lists))))
     903              (fold-right cons tail list1)) ; Append LIST1 & TAIL.
     904            list1))
     905      '()))
     906
    896907
    897908(define-syntax string-ec
    898909  (syntax-rules ()