Changeset 39550 in project


Ignore:
Timestamp:
01/29/21 05:27:30 (5 weeks ago)
Author:
Kon Lovett
Message:

add comma-list-utils, add list-flatten

Location:
release/5/list-utils/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • release/5/list-utils/trunk/list-utils.egg

    r39547 r39550  
    33
    44((synopsis "list-utils")
    5  (version "2.2.0")
     5 (version "2.3.0")
    66 (category data)
    77 (author "Kon Lovett")
    88 (license "BSD")
    9  (dependencies srfi-1 check-errors)
     9 (dependencies utf8 srfi-1 check-errors)
    1010 (test-dependencies test)
    1111 (components
     
    1313    (types-file)
    1414    (csc-options
     15      "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks"))
     16  (extension comma-list-utils
     17    (types-file)
     18    (component-dependencies list-utils)
     19    (csc-options
    1520      "-O3" "-d1" "-strict-types" "-no-procedure-checks" "-no-bound-checks")) ) )
  • release/5/list-utils/trunk/list-utils.scm

    r39547 r39550  
    1515  section
    1616  length=0? length=1? length=2? length>1?
     17  ensure-flat-list list-flatten
    1718  ensure-list
    1819  not-null?
     
    4142    take drop
    4243    every
    43     split-at)
     44    split-at
     45    concatenate)
    4446  (only type-checks
    4547    check-list check-alist check-pair
     
    6769(: alist-delete-duplicates (* alist #!optional binary-test fixnum --> alist))
    6870(: alist-delete-duplicates! (* alist #!optional binary-test fixnum --> alist))
     71(: ensure-flat-list (* -> list))
     72(: list-flatten (list -> list))
    6973(: zip-alist (list list --> alist))
    7074(: unzip-alist (alist --> list list))
     
    243247;; Returns a list
    244248
     249(define (ensure-flat-list x)
     250  (cond
     251    ((null? x)  x)
     252    ((pair? x)  (list-flatten x))
     253    (else       (list x)) ) )
     254
     255(define (list-flatten ls)
     256  (concatenate (map ensure-flat-list ls)) )
     257
     258;; Returns a list
     259
    245260(define-syntax ensure-list
    246261        (syntax-rules ()
  • release/5/list-utils/trunk/tests/list-utils-test.scm

    r39547 r39550  
    1313  (test '((a b c d e) (a d)) (receive (list-unique/duplicates '(a a b c d d e))))
    1414  (test '(a b c d e) (list-unique '(a a b c d d e)))
     15)
     16
     17(test-group  "Flat"
     18  (test '(a b c d e f g) (list-flatten '((a) b ((((c) d) e) f) g)))
    1519)
    1620
     
    158162)
    159163
     164(import comma-list-utils)
     165
     166(test-group  "comma-list-utils"
     167  (test "1, 2, 3" (list-comma-join 1 2 3))
     168  (test '("1" "2" "3") (comma-string->list "1, 2, 3"))
     169)
     170
    160171;;;
    161172
Note: See TracChangeset for help on using the changeset viewer.