function Pow { param( $base, $pow ) [Math]::Pow( $base, $pow ) }
filter fPow { param( $Pow ) [Math]::Pow( $_, $pow ) }
filter IPow { param( $Base ) [Math]::Pow( $base, $_ ) }
function Csv { $input | Join-String -sep ', ' }3 Different interfaces
Pow 2 7
# 128
Pow ( Pow 2 18 ) 2
# 68719476736
Pow ( Pow 16 2 ) ( 1 / 2 ) # === sqrt( 16^2 ) = 16
# 160..16 | fPow 4 | Csv
# 0, 1, 16, 81, 256, 625, 1296, 2401, 4096, 6561, 10000, 14641, 20736, 28561, 38416, 50625, 65536
0..16 | IPow 2 | Csv
# 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536 1 | IPow 2
# 4
1 | IPow 2 | IPow 2 | IPow 2
# 2
1 | IPow 2 | IPow 2 | IPow 2
# 16
Pow 2 2 | FPow 4
# 256
Pow 2 2 | FPow 4 | FPow (1/2)
# 16
1 | IPow 2 | IPow 2 | IPow 2 | FPow 2
# 256
1 | IPow 2 | IPow 2 | IPow 2 | FPow (1/2)
# 4
The names fpow/ipow are confusing
I started with them as 'filter/inverse filter'.
so that I didn't overwrite the Pow name
They are the same, it's just whether the powers are constant, or come from the pipeline:
Fpow 4
# is
Pow -Base $x -Power 4Ipow 4
# is
Pow -Base 4 -Power $x