@@ -69,7 +69,7 @@ Looking for Transducers in other Lisps? Check out the [[https://github.com/fossk
6969 - [[#string-base-string][string, base-string]]
7070 - [[#hash-table][hash-table]]
7171 - [[#count-quantities][count, quantities]]
72- - [[#average-median][average, median]]
72+ - [[#average-median-ratio ][average, median, ratio ]]
7373 - [[#any-all][any?, all?]]
7474 - [[#partition][partition]]
7575 - [[#first-last-find][first, last, find]]
@@ -750,9 +750,9 @@ predicate.
750750#+RESULTS:
751751: #<COMMON-LISP:HASH-TABLE :TEST EQL :COUNT 5 {10094FE823}>
752752
753- *** average, median
753+ *** average, median, ratio
754754
755- Calculate the average value of all numeric elements in a transduction.
755+ =average=: Calculate the average value of all numeric elements in a transduction.
756756
757757#+begin_src lisp :exports both
758758(in-package :transducers)
@@ -762,9 +762,9 @@ Calculate the average value of all numeric elements in a transduction.
762762#+RESULTS:
763763: 7/2
764764
765- Calculate the median value of all elements in a transduction, provided that they
766- are numbers, strings, or characters. The elements are sorted once before the
767- median is extracted.
765+ =median=: Calculate the median value of all elements in a transduction, provided
766+ that they are numbers, strings, or characters. The elements are sorted once
767+ before the median is extracted.
768768
769769#+begin_src lisp :exports both
770770(in-package :transducers)
@@ -774,6 +774,17 @@ median is extracted.
774774#+RESULTS:
775775: 1
776776
777+ =ratio=: The percentage of items that satisfied a predicate. The final value will
778+ always be between 0 and 1.
779+
780+ #+begin_src lisp :exports both
781+ (in-package :transducers)
782+ (transduce #'pass (ratio #'evenp) #(1 2 3 4 5 6))
783+ #+end_src
784+
785+ #+RESULTS:
786+ : 1/2
787+
777788*** any?, all?
778789
779790Yield =t= if any element in the transduction satisfies PRED. Short-circuits the
0 commit comments