我需要交换给定两个位置(i,j)的列表元素,以便为TSP实施2-opt启发式,并发现this question建议使用rotatef
。
然而,当我尝试使用它时,我无法理解它的行为。
这段代码令我头疼:
(setq loop '(A B C D E F))
> (A B C D E F)
;; Original copy saved in loop
(setq new_tour loop)
(format t "ORIGINAL LOOP: " loop)
> LOOP: (A B C D E F)
(format t "NEW_TOUR: " new_tour)
> NEW_TOUR: (A B C D E F)
(rotatef (nth 0 new_tour) (nth 1 new_tour))
(format t "NEW_TOUR IS NOW: ~a~%" new_tour)
> NEW_TOUR IS NOW: (B A C D E F)
(format t "ORIGINAL LOOP IS NOW: ~a~%" loop)
> ORIGINAL LOOP IS NOW: (B A C D E F)
为什么rotatef
也会修改'循环'清单?有没有办法交换new_tour
的元素而不会丢失原始列表(loop
)?
答案 0 :(得分:5)
复制Remove-MailboxPermission
使用
try
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Remove-MailboxPermission -Identity "test2" -User "test1" -AccessRights FullAccess -InheritanceType All -confirm:$False -WarningAction Stop -ErrorAction Stop | Out-File c:\temp\output2.txt -Encoding ASCII
}
catch
{
#Write-Warning -Message $($_.Exception.Message) 3 > c:\temp\warning.txt
}