Changeset 39355 in project


Ignore:
Timestamp:
11/23/20 22:24:04 (8 weeks ago)
Author:
Kon Lovett
Message:

add types include(s), simplify seq-utils list use

Location:
release/5/micro-stats/trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/micro-stats/trunk/micro-stats.scm

    r39353 r39355  
    2828;;;
    2929
    30 ;FIXME should be in an include file from the seq-utils egg but C5 bug
    31 (define-type seq (or list vector string #;linear-sequence #;random-access-sequence))
    32 (define-type binary-predicate (* * --> boolean))
    33 (define-type alist (or null (list-of (pair * *))))
    34 (define-type histogram-list list)
    35 
    36 (define-type real (or integer float ratnum))
    37 
    38 (define-type statistics-alist (or null (list-of (pair symbol *))))
    39 
    40 (define-type statistics-set-id (or symbol boolean))
     30(include "micro-stats-types")
    4131
    4232(: statistics-sets (#!optional alist -> alist))
     
    4737(: generate-statistics-sublist (seq list #!optional vector --> (pair symbol *)))
    4838
    49 (: chi-sample (seq (or real seq) --> real))
    50 (: chi-squares (seq seq --> seq))
    51 (: chi-square (seq (or real seq) --> real))
    5239(: variance (seq real --> real))
    5340(: standard-deviation (seq #!optional real --> real real))
     
    5744(: mean (seq --> real real real))
    5845(: percentile (seq #!optional real binary-predicate --> real))
     46
     47(: chi-sample (seq (or real seq) --> real))
     48(: chi-squares (seq seq --> seq))
     49(: chi-square (seq (or real seq) --> real))
    5950
    6051;;;
  • release/5/micro-stats/trunk/seq-utils.scm

    r39353 r39355  
    2020;;;
    2121
    22 ;(define-type seq (or list vector string linear-sequence random-access-sequence))
    23 (define-type seq (or list vector string))
     22(include "seq-utils-types")
    2423
    25 (define-type binary-predicate (* * --> boolean))
    26 
    27 (define-type alist (or null (list-of (pair * *))))
    28 
    29 (define-type histogram-list list)
    30 
    31 (: sorted? (seq binary-predicate --> boolean))
    3224(: merge! (seq seq binary-predicate -> seq))
    3325(: merge (seq seq binary-predicate -> seq))
     26(: sorted? (seq binary-predicate --> boolean))
    3427(: sort! (seq binary-predicate -> seq))
    3528(: sort (seq binary-predicate -> seq))
     
    4235(define *empty-list* (list))
    4336
    44 (define (sorted? seq less?)
    45   (let ((seqv (if (or (list? seq) (vector? seq)) seq (seq:coerce *empty-list* seq))))
    46     (chicken:sorted? seqv less?) ) )
     37(define (seq->list x) (if (list? x) x (seq:coerce *empty-list* x)))
    4738
    4839(define (merge! a b less?)
    49   (let* (
    50     (as (if (list? a) a (seq:coerce *empty-list* a)))
    51     (bs (if (list? b) b (seq:coerce *empty-list* b)))
    52     (rs (chicken:merge! as bs less?)) )
     40  (let ((rs (chicken:merge! (seq->list a) (seq->list b) less?)))
    5341    (if (list? a) rs (seq:coerce a rs)) ) )
    5442
    5543(define (merge a b less?)
    56   (let* (
    57     (as (if (list? a) a (seq:coerce *empty-list* a)))
    58     (bs (if (list? b) b (seq:coerce *empty-list* b)))
    59     (rs (chicken:merge as bs less?)) )
     44  (let ((rs (chicken:merge (seq->list a) (seq->list b) less?)))
    6045    (if (list? a) rs (seq:coerce a rs)) ) )
     46
     47(define (sorted? seq less?)
     48  (let ((ss (if (vector? seq) seq (seq->list seq))))
     49    (chicken:sorted? ss less?) ) )
    6150
    6251(define (sort! seq less?)
    6352  ;FIXME fill-in original from sorted-list
    6453  (let* (
    65     (seqv (if (or (list? seq) (vector? seq)) seq (seq:coerce *empty-list* seq)))
    66     (rs (chicken:sort! seqv less?)) )
     54    (ss (if (vector? seq) seq (seq->list seq)))
     55    (rs (chicken:sort! ss less?)) )
    6756    (if (or (list? seq) (vector? seq)) rs (seq:coerce seq rs)) ) )
    6857
    6958(define (sort seq less?)
    70   (seq:coerce seq (chicken:sort! (seq:coerce *empty-list* seq) less?)) )
     59  (seq:coerce seq (chicken:sort! (seq->list seq) less?)) )
    7160
    7261;;
Note: See TracChangeset for help on using the changeset viewer.