Entropy: Difference between revisions
Content added Content deleted
Drkameleon (talk | contribs) (Added Arturo implementation) |
|||
Line 241: | Line 241: | ||
1.846439345 |
1.846439345 |
||
</pre> |
</pre> |
||
=={{header|Arturo}}== |
|||
<lang rebol>entropy: function [s][ |
|||
t: #[] |
|||
loop s 'c [ |
|||
unless key? t c -> t\[c]: 0 |
|||
t\[c]: t\[c] + 1 |
|||
] |
|||
result: new 0 |
|||
loop values t 'x -> |
|||
'result - (x//(size s)) * log x//(size s) 2 |
|||
return result |
|||
] |
|||
print entropy "1223334444"</lang> |
|||
{{out}} |
|||
<pre>1.846439344671015</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |