Changeset 40460 in project


Ignore:
Timestamp:
09/08/21 18:32:06 (2 weeks ago)
Author:
Kon Lovett
Message:

most procs are pure, add string-split-chars, new test runner

Location:
release/5/string-utils/trunk
Files:
4 edited

Legend:

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

    r39995 r40460  
    33
    44((synopsis "String Utilities")
    5  (version "2.5.2")
     5 (version "2.5.3")
    66 (category data)
    77 (author "Kon Lovett")
  • release/5/string-utils/trunk/string-utils.scm

    r39836 r40460  
    77
    88(;export
    9   string-unzip
    10   string-zip
     9  string-split-chars
     10  string-unzip string-zip
    1111  string-trim-whitespace-both
    1212  list-as-string
     
    3434;;
    3535
    36 (: string-unzip (string string -> (list-of string) (list-of string)))
    37 (: string-zip   ((list-of string) (list-of string) -> string))
    38 
    39 (: string-trim-whitespace-both  (string -> string))
    40 (: list-as-string               (list -> string))
    41 (: number->padded-string        (number fixnum #!optional char fixnum -> string))
    42 (: string-fixed-length          (string fixnum #!rest -> string))
    43 
    44 (: *string-longest-common-prefix  ((list-of (list-of char)) -> (list-of char)))
    45 (: string-longest-common-prefix   ((list-of string) -> string))
    46 (: string-longest-common-suffix   ((list-of string) -> string))
    47 
    48 (: *string-longest-prefix (string (list-of string) procedure -> *))
    49 (: string-longest-prefix  (string (list-of string) -> (or boolean string)))
    50 (: string-longest-suffix  (string (list-of string) -> (or boolean string)))
     36(: string-split-chars (string string --> (list-of string) (list-of char)))
     37
     38(: string-unzip (string string --> (list-of string) (list-of string)))
     39(: string-zip   ((list-of string) (list-of string) --> string))
     40
     41(: string-trim-whitespace-both  (string --> string))
     42(: list-as-string               (list --> string))
     43(: number->padded-string        (number fixnum #!optional char fixnum --> string))
     44(: string-fixed-length          (string fixnum #!rest --> string))
     45
     46(: *string-longest-common-prefix  ((list-of (list-of char)) --> (list-of char)))
     47(: string-longest-common-prefix   ((list-of string) --> string))
     48(: string-longest-common-suffix   ((list-of string) --> string))
     49
     50(: *string-longest-prefix (string (list-of string) procedure --> *))
     51(: string-longest-prefix  (string (list-of string) --> (or boolean string)))
     52(: string-longest-suffix  (string (list-of string) --> (or boolean string)))
    5153
    5254;;
     
    6769;NOTE irregex-split doesn't preserve "missing" so punct vs parts is ambiguous
    6870
     71;"..." => string-parts char-punct
     72;"a.3,c" => ("a" "3" "c") (#\. #\,)
     73(define (string-split-chars str puncs)
     74  (let (
     75    (parts (string-split str puncs #t))
     76    (punct (string->list (string-filter (cut string-index puncs <>) str))) )
     77    (values parts punct) ) )
     78
    6979;"..." => parts punct
    7080;"a.b,c" => ("a" "b" "c") ("." ",")
    71 (define (string-unzip str punct-str)
    72   (let (
    73     (parts (string-split str punct-str #t))
    74     (punct (map string (string->list (string-filter (cut string-index punct-str <>) str)))) )
    75     (values parts punct) ) )
     81(define (string-unzip str puncs)
     82  (let-values (((parts punct) (string-split-chars str puncs)))
     83    (values parts (map string punct)) ) )
    7684
    7785;punct parts => ?
     
    210218  (define (longest coalesced)
    211219    (filter
    212       identity
     220      identity  ;?????
    213221      (append-map
    214222        (lambda (cell)
  • release/5/string-utils/trunk/tests/run.scm

    r39822 r40460  
    77    make-pathname pathname-file pathname-replace-directory pathname-strip-extension)
    88  (only (chicken process) system)
    9   (only (chicken process-context) command-line-arguments)
     9  (only (chicken process-context) command-line-arguments get-environment-variable)
    1010  (only (chicken format) format)
    1111  (only (chicken file) file-exists? find-files)
     
    1313
    1414;; Globals
     15
     16(define *csi* (or (get-environment-variable "CHICKEN_CSI") "csi"))
     17(define *csc* (or (get-environment-variable "CHICKEN_CSC") "csc"))
    1518
    1619(define *csc-init-options* '(
     
    7982
    8083(define (run-test-evaluated source)
    81   (format #t "*** csi ~A ***~%" (pathname-file source))
    82   (system-must (string-append "csi -s " source)) )
     84  (format #t "*** ~A ~A ***~%" *csi* (pathname-file source))
     85  (system-must (string-append *csi* " -s " source)) )
    8386
    8487(define (run-test-compiled source csc-options)
    8588  (let ((optstr (apply string-append (intersperse csc-options " "))))
    86     (format #t "*** csc ~A ~A ***~%" (pathname-file source) optstr)
     89    (format #t "*** ~A ~A ~A ***~%" *csc* (pathname-file source) optstr)
    8790    ;csc output is in current directory
    88     (system-must (string-append "csc" " " optstr " " source)) )
     91    (system-must (string-append *csc* " " optstr " " source)) )
    8992  (system-must (pathname-replace-directory (pathname-strip-extension source) *test-directory*)) )
    9093
  • release/5/string-utils/trunk/unicode-utils.scm

    r39956 r40460  
    3737(: ascii-codepoint? (* --> boolean))
    3838(: unicode-surrogate? (* --> boolean))
    39 (: char->unicode-string (char -> string))
     39(: char->unicode-string (char --> string))
    4040(: unicode-char->string (deprecated char->unicode-string))
    41 (: *unicode-string ((list-of char) -> string))
    42 (: unicode-string (#!rest -> string))
    43 (: *unicode-make-string (fixnum char -> string))
    44 (: unicode-make-string (fixnum #!optional char -> string))
    45 (: unicode-surrogates->codepoint (fixnum fixnum -> (or boolean fixnum)))
     41(: *unicode-string ((list-of char) --> string))
     42(: unicode-string (#!rest --> string))
     43(: *unicode-make-string (fixnum char --> string))
     44(: unicode-make-string (fixnum #!optional char --> string))
     45(: unicode-surrogates->codepoint (fixnum fixnum --> (or boolean fixnum)))
    4646
    4747;; Simple UTF 8
Note: See TracChangeset for help on using the changeset viewer.