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.

Revisions

  1. Xainey created this gist Feb 16, 2017.
    33 changes: 33 additions & 0 deletions P-P-A-P.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    $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 "-")
    }
    }