Skip to content

Commit

Permalink
math.extras: adding nonzero.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Jun 19, 2012
1 parent 023898f commit 3006999
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extra/math/extras/extras-tests.factor
Expand Up @@ -20,3 +20,6 @@ IN: math.extras.test
[ 10 [1,b] 2 exponential-moving-average ] unit-test

{ { 2 5 5 4 3 } } [ { 1 2 5 6 1 4 3 } 3 moving-median ] unit-test

{ { } } [ { 0 0 } nonzero ] unit-test
{ { 1 2 3 } } [ { 0 1 0 2 0 3 0 } nonzero ] unit-test
3 changes: 3 additions & 0 deletions extra/math/extras/extras.factor
Expand Up @@ -94,3 +94,6 @@ PRIVATE>

: moving-median ( u n -- v )
<clumps> [ median ] map ;

: nonzero ( seq -- seq' )
[ zero? not ] filter ;

0 comments on commit 3006999

Please sign in to comment.