Apl2ToDo/BooleanTestsNumericAlgorithms

This is a sub-page of PhraseBook/ToDo/Apl2Idioms

BS←≠/0 1εB ⍝ Boolean test: All items in simple B equal?

BS←≠/0 1εεAB ⍝ Boolean test: All items in B equal?

BS←AB≡1⌽AB ⍝ Boolean test: All items in B equal?

BS←^/B ⍝ Boolean test: Are all true?

BS←∨/B ⍝ Boolean test: Are any true?

BS←~∨/B ⍝ Boolean test: Are none true?

BS←≠/B ⍝ Boolean test: Parity.

BS←^/εBε0 1 ⍝ Boolean test: Is B boolean?

BS←(↑0⍴⊂A)≡(⍴A)⍴0 ⍝ Boolean test: Is A simple numeric?

BS←0=↑0⍴A ⍝ Boolean test: Is A numeric? (if homogeneous)

BS←~×↑⍒N ⍝ Boolean test: Is first item largest?

BS←|/⍋N ⍝ Boolean test: Is first item largest?

BS←~×↑⍋N ⍝ Boolean test: Is first item smallest?

BS←|/⍒N ⍝ Boolean test: Is first item smallest?

BS←∨/~2|N ⍝ Boolean test: Is any element of N even?

BS←^/2|N ⍝ Boolean test: Is every element of N odd?

BS←^/N>0 ⍝ Boolean test: Is every element of N positive?

BS←^⌿N=⌈⍀N ⍝ Boolean test: Is N in ascending column order.

BS←^/N=⌈\N ⍝ Boolean test: Is N in ascending row order.

BS←N[⍋N]≡1+⍳⍴N ⍝ Boolean test: Is N permutation vector?

BS←N[⍋N]≡⍳⍴N ⍝ Boolean test: Is N permutation vector?

BS←N[⍋N]≡NX[⍋NX] ⍝ Boolean test: Is N permutation of NX?

BS←^/ε~2|NA ⍝ Boolean test: Is every element of NA even?

BS←^/εNA=⌊NA ⍝ Boolean test: Is every element of NA integer?

BS←0=+/0=((2×IS≠2),3+2×⍳⌊.5×IS*.5)|IS ⍝ Boolean test: Is IS prime?

BS←0=+/0=((2×IS≠2),1+2×⍳⌊.5×IS*.5)|IS ⍝ Boolean test: Is IS prime?

B←</(N<⌈N),N∘.<XY ⍝ Is N an integer in range [XY) XY ←→ lo,hi.

B←((↑XY)<N)^N<↑⌽XY ⍝ Is N in range (XY) XY ←→ lo,hi.

B←</N∘.<XY ⍝ Is N in range [XY) XY ←→ lo,hi.

B←>/N∘.>XY ⍝ Is N in range (XY] XY ←→ lo,hi.

B←((↑XY)≤N)^N≤↑⌽XY ⍝ Is N in range [XY] XY ←→ lo,hi.

BS←0≠.=N ⍝ Ain't Dot Is. Test for even # of non-zeros.

BS←↑≡/X Y fn Y X ⍝ Test for commutativity of fn.

BS←((V f1 X)f2 Y)≡V f1 X f2 Y ⍝ Test for associativity of f1 and f2.

BS←((V f1 X)f2 Y)≡↑f1/V X f2⊂Y ⍝ Test for distributivity of f1 and f2.

Apl2ToDo/BooleanTestsNumericAlgorithms (last edited 2011-04-25 12:28:23 by KaiJaeger)