File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -552,7 +552,8 @@ impl Value {
552552 pub ( crate ) fn unkeep ( self , env : & Uiua ) -> UiuaResult < ( Self , Self ) > {
553553 val_as_arr ! ( self , |a| a. unkeep( env) . map( |( a, b) | ( a, b. into( ) ) ) )
554554 }
555- pub ( crate ) fn anti_keep ( self , kept : Self , env : & Uiua ) -> UiuaResult < Self > {
555+ pub ( crate ) fn anti_keep ( self , mut kept : Self , env : & Uiua ) -> UiuaResult < Self > {
556+ kept. match_fill ( env) ;
556557 let counts = self . as_nums ( env, "Keep amount must be a list of natural numbers" ) ?;
557558 Ok ( if self . rank ( ) == 0 {
558559 if counts[ 0 ] == 0.0 {
@@ -814,6 +815,9 @@ impl<T: ArrayValue> Array<T> {
814815 return Err ( env. error ( "Anti keep amount must be a list of booleans" ) ) ;
815816 }
816817 let trues = counts. iter ( ) . filter ( |& & n| n == 1.0 ) . count ( ) ;
818+ if trues == 0 {
819+ return Err ( env. error ( "Cannot anti keep with all 0 counts" ) ) ;
820+ }
817821 let falses = counts. iter ( ) . filter ( |& & n| n == 0.0 ) . count ( ) ;
818822 let target_len = self . row_count ( ) . max (
819823 ( self . row_count ( ) as f64 * ( trues + falses) as f64 / trues as f64 ) . floor ( ) as usize ,
Original file line number Diff line number Diff line change @@ -177,3 +177,5 @@ F ← |0.1000 ⍢(F F F|1)
177177┌─╴A
178178 B ← A
179179└─╴
180+
181+ ⬚0⌝▽ 0_0 1_2
You can’t perform that action at this time.
0 commit comments