Jump to content

Narcissist: Difference between revisions

Added PowerShell
(Added Befunge example.)
(Added PowerShell)
Line 251:
<pre>: (narcissist "(Str) (= Str (str narcissist))")
-> T</pre>
 
=={{header|PowerShell}}==
<lang PowerShell>
function entropy ($string) {
$n = $string.Length
$string.ToCharArray() | group | foreach{
$p = $_.Count/$n
$i = [Math]::Log($p,2)
-$p*$i
} | measure -Sum | foreach Sum
}
entropy $(get-content "$($MyInvocation.MyCommand.Name )" -Raw)
</lang>
<pre>
4.74418336918292
</pre>
 
=={{header|Python}}==
678

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.