Changeset 39355 in project
 Timestamp:
 11/23/20 22:24:04 (8 weeks ago)
 Location:
 release/5/microstats/trunk
 Files:

 2 added
 2 edited
Legend:
 Unmodified
 Added
 Removed

release/5/microstats/trunk/microstats.scm
r39353 r39355 28 28 ;;; 29 29 30 ;FIXME should be in an include file from the sequtils egg but C5 bug 31 (definetype seq (or list vector string #;linearsequence #;randomaccesssequence)) 32 (definetype binarypredicate (* * > boolean)) 33 (definetype alist (or null (listof (pair * *)))) 34 (definetype histogramlist list) 35 36 (definetype real (or integer float ratnum)) 37 38 (definetype statisticsalist (or null (listof (pair symbol *)))) 39 40 (definetype statisticssetid (or symbol boolean)) 30 (include "microstatstypes") 41 31 42 32 (: statisticssets (#!optional alist > alist)) … … 47 37 (: generatestatisticssublist (seq list #!optional vector > (pair symbol *))) 48 38 49 (: chisample (seq (or real seq) > real))50 (: chisquares (seq seq > seq))51 (: chisquare (seq (or real seq) > real))52 39 (: variance (seq real > real)) 53 40 (: standarddeviation (seq #!optional real > real real)) … … 57 44 (: mean (seq > real real real)) 58 45 (: percentile (seq #!optional real binarypredicate > real)) 46 47 (: chisample (seq (or real seq) > real)) 48 (: chisquares (seq seq > seq)) 49 (: chisquare (seq (or real seq) > real)) 59 50 60 51 ;;; 
release/5/microstats/trunk/sequtils.scm
r39353 r39355 20 20 ;;; 21 21 22 ;(definetype seq (or list vector string linearsequence randomaccesssequence)) 23 (definetype seq (or list vector string)) 22 (include "sequtilstypes") 24 23 25 (definetype binarypredicate (* * > boolean))26 27 (definetype alist (or null (listof (pair * *))))28 29 (definetype histogramlist list)30 31 (: sorted? (seq binarypredicate > boolean))32 24 (: merge! (seq seq binarypredicate > seq)) 33 25 (: merge (seq seq binarypredicate > seq)) 26 (: sorted? (seq binarypredicate > boolean)) 34 27 (: sort! (seq binarypredicate > seq)) 35 28 (: sort (seq binarypredicate > seq)) … … 42 35 (define *emptylist* (list)) 43 36 44 (define (sorted? seq less?) 45 (let ((seqv (if (or (list? seq) (vector? seq)) seq (seq:coerce *emptylist* seq)))) 46 (chicken:sorted? seqv less?) ) ) 37 (define (seq>list x) (if (list? x) x (seq:coerce *emptylist* x))) 47 38 48 39 (define (merge! a b less?) 49 (let* ( 50 (as (if (list? a) a (seq:coerce *emptylist* a))) 51 (bs (if (list? b) b (seq:coerce *emptylist* b))) 52 (rs (chicken:merge! as bs less?)) ) 40 (let ((rs (chicken:merge! (seq>list a) (seq>list b) less?))) 53 41 (if (list? a) rs (seq:coerce a rs)) ) ) 54 42 55 43 (define (merge a b less?) 56 (let* ( 57 (as (if (list? a) a (seq:coerce *emptylist* a))) 58 (bs (if (list? b) b (seq:coerce *emptylist* b))) 59 (rs (chicken:merge as bs less?)) ) 44 (let ((rs (chicken:merge (seq>list a) (seq>list b) less?))) 60 45 (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?) ) ) 61 50 62 51 (define (sort! seq less?) 63 52 ;FIXME fillin original from sortedlist 64 53 (let* ( 65 (s eqv (if (or (list? seq) (vector? seq)) seq (seq:coerce *emptylist*seq)))66 (rs (chicken:sort! s eqvless?)) )54 (ss (if (vector? seq) seq (seq>list seq))) 55 (rs (chicken:sort! ss less?)) ) 67 56 (if (or (list? seq) (vector? seq)) rs (seq:coerce seq rs)) ) ) 68 57 69 58 (define (sort seq less?) 70 (seq:coerce seq (chicken:sort! (seq :coerce *emptylist*seq) less?)) )59 (seq:coerce seq (chicken:sort! (seq>list seq) less?)) ) 71 60 72 61 ;;
Note: See TracChangeset
for help on using the changeset viewer.