Created
February 16, 2017 07:57
-
-
Save Xainey/5b0c464e71d2c95ba6581f8b2bc98b46 to your computer and use it in GitHub Desktop.
Finally got to test PowerShell on my Mac :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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