Skip to content

Instantly share code, notes, and snippets.

@Xainey
Created February 16, 2017 07:57
Show Gist options
  • Save Xainey/5b0c464e71d2c95ba6581f8b2bc98b46 to your computer and use it in GitHub Desktop.
Save Xainey/5b0c464e71d2c95ba6581f8b2bc98b46 to your computer and use it in GitHub Desktop.
Finally got to test PowerShell on my Mac :)
$stack = New-Object System.Collections.Stack
function I {
if($args[$args.Count - 1]){
$stack.push($args[$args.Count - 1])
}
}
function UH! {
if($stack.Count -ge 2){
$r = "{0}-{1}!" -f $stack.Pop(), $stack.Pop()
if($stack.count -eq 0){
$stack.Push($r)
}
}
elseif($stack.Count -eq 1){
$r = $stack.Peek()
}
Write-Host $r -ForegroundColor Green
# return $r
}
function _ ($arr){
$stack.Clear()
for($i = 0; $i -lt $arr.count; $i++){
$pieces = $arr[$i] -split "-"
if($i % 2 -ne 0){
[array]::Reverse($pieces)
}
$stack.Push($pieces -join "-")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment