Created
December 6, 2017 15:20
-
-
Save nohwnd/e5773c6b1514c88e6beb3fc80252d20f to your computer and use it in GitHub Desktop.
emojicode in PowerShell
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
function π { | |
$name,$params = $args.Where({$_ -eq 'π©'},'Until') | |
$null,$groups = $args.Where({$_ -eq 'π©'},'SkipUntil') | |
$params = @($params |? {$_}) | |
$bodyText = $groups | %{ | |
$enumerator = [System.Globalization.StringInfo]::GetTextElementEnumerator($_) | |
$letters = while ($enumerator.MoveNext()) | |
{ | |
$enumerator.Current | |
} | |
$literal = $false | |
$body = $letters | % { | |
if ($_ -eq "π€") | |
{ | |
$literal = -not $literal | |
"'" | |
} elseif ((-not $literal) -and ( Get-Command $_ -ErrorAction SilentlyContinue)) | |
{ | |
"(&(Get-Command $_))" | |
} | |
elseif ((-not $literal) -and ( $_ -in $params)) { | |
$c = [Guid]::NewGuid().ToString('N') | |
"(&{if (`$$c=(Get-Command `${$_} -ErrorAction silentlyContinue)) { &`$$c } else { `${$_} }})" | |
} | |
else | |
{ | |
$_ | |
} | |
} | |
$body -join '' | |
} | |
$func = @" | |
param($(($params |% {"`${$_}"})-join',')) | |
$bodyText | |
"@ | |
"function global:$name {$func}" |Invoke-Expression | |
} | |
π π₯ π© π€π₯π€ | |
π 1οΈβ£ π© 1 | |
π 2οΈβ£ π© 2 | |
π β π ° π ± π© π °+π ± | |
'bacon definition' | |
get-command π₯ | % definition | |
'plus definition' | |
get-command β | % definition | |
β π₯ π₯ | |
β 1οΈβ£ 2οΈβ£ | |
β 1 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment