我想知道是否有一种方法可以不使用乘法将正数变成负数,就像$b = $a * -1
我正在寻找最成本合理的方法一样,因为我会在脚本中多次这样做。
-edit 此时我正在使用它,但看起来计算成本非常高:
$temp_array = New-Object 'object[,]' $this.row,$this.col
for ($i=0;$i -le $this.row -1 ; $i++) {
for ($j=0;$j -le $this.col -1 ; $j++) {
$digit = $this.data[$i,$j] * -1
$temp_array[$i,$j] = 1 / ( 1 + [math]::exp( $digit ) )
#[math]::Round( $digit ,3)
}
}
$this.data = $temp_array
Run Code Online (Sandbox Code Playgroud) 我正在创建一个名为get_other_sites的函数.但我认为有一种比我现在做的更好或更快的方式.
function get_other_sites($curent_site){
if ($curent_site == 'site1.com'){
echo"
<a href='site2.com'>site2.com</a>
<a href='site3.com'>site3.com</a>
<a href='site4.com'>site4.com</a>
<a href='site5.com'>site5.com</a>
";
}
else if ($curent_site == 'site2.com'){
echo"
<a href='site1.com'>site1.com</a>
<a href='site3.com'>site3.com</a>
<a href='site4.com'>site4.com</a>
<a href='site5.com'>site5.com</a>
";
}
else if ($curent_site == 'site3.com'){
echo"
<a href='site1.com'>site1.com</a>
<a href='site2.com'>site2.com</a>
<a href='site4.com'>site4.com</a>
<a href='site5.com'>site5.com</a>
";
}
}
Run Code Online (Sandbox Code Playgroud)
对于这个问题,我让它更容易阅读,但网站列表要长得多.有人知道一个更好的方法来做这个很少的文字吗?
提前致谢.