lib/Ay.ps1
function Ay {$args} function Ay-PSCusObj ([Array]$prpVal,[string]$prpNmStr) { $o=@{}; $ny = Split-Spc $prpNmStr; $ub=ub $ny; (0..$ub) | % {$o.Add($ny.$_,$prpVal.$_)}; [PSCustomObject]$o } function Obj-Ay ($obj,$prpNmStr) {(Split-Spc $prpNmStr)|%{$obj.$_} } function Push-NoDup ($ay,$s) {if((Is-Empty $s)-or($ay-contains $s)){$ay}else{$ay+(,$s)}} function Push-NonEmpty($ay,$s) {if(Is-Empty $s){$ay}else{$ay+(,$s)} } function Ay-Idx ($ay,$ele) {$ay.IndexOf($ele)} function Quote-Ay ($ay,$quote) {$1,$2=Brk-Quote $quote;$ay|%{$1+$_+$2} } function Max-Ele ($ay){$o=$null;$ay|%{if($o -lt $_){$o=$_}};$o} function Stringify-Ay ($ay){$ay|%{"$_"}} function Is-SomTrue ($ay){$somT=$false;foreach($_ in $ay){if( $_){$somT=$true ;break}};$somT} function Is-AllTrue ($ay){$allT=$true ;foreach($_ in $ay){if(!$_){$allT=$false;break}};$allT} function Is-SomFalse ($ay){$somF=$false;foreach($_ in $ay){if(!$_){$somF=$true ;break}};$somF} function Is-AllFalse ($ay){$allF=$true ;foreach($_ in $ay){if( $_){$allF=$false;break}};$allF} function Sz ($ay) {$ay.Count } function ReSz ([ref]$ay,$newUb) {[Array]::Resize($ay,$newUb+1);$ay.Value} function Ub ($ay) {(Sz $ay)-1} function Reverse-Ay ($ay) {($(Ub $ay)..0)|%{$ay[$_]}} function Rmv-Dup ($ay) {$o=@(); $ay|%{if(!($o -contains $_)){$o+=(,$_)}}; $o} function Rmv-EmptyEle ($ay) {$ay|where{Is-NonEmpty $_}} function Sum-Ay ($ay) {[double]$o=0;$ay|%{$o+=$_};$o} function Minus-Ay ($ay1,$ay2) {$ay1|%{if(-not($ay2 -contains $_)){$_}}} function Ay-Rg ($ay) {$u=Ub $args;if(Is-Even $u){throw 'Parameter after $ay should be in pair' } for($i=0;$i-le $u;$i+=2){ $1=$args[$i] $2=$args[$i+1] if($2-ge $1){ ($1..$2)|%{$ay[$_]} } } } function Macro-Ay($macroStr, [switch]$inclBkt) { $o = ($macroStr -split '\{') | Where {Has-Sub $_ '}'} | %{Fst $_ '}'} if($inclBkt){$o=($o|%{Quote $_ '{}'})} Rmv-Dup $o } |