Jump to content

Entropy/Narcissist: Difference between revisions

added Factor
(Added Erlang version)
(added Factor)
Line 177:
My entropy is 5.00988934931771
</pre>
 
=={{header|Factor}}==
<lang factor>USING: assocs io io.encodings.utf8 io.files kernel math
math.functions math.statistics prettyprint sequences ;
IN: rosetta-code.entropy-narcissist
 
: entropy ( seq -- entropy )
[ length ] [ histogram >alist [ second ] map ] bi
[ swap / ] with map
[ dup log 2 log / * ] map-sum neg ;
 
"entropy-narcissist.factor" utf8 [
contents entropy .
] with-file-reader</lang>
{{out}}
<pre>
4.591946214804276
</pre>
 
=={{header|FreeBASIC}}==
<lang FreeBASIC>' version 01-06-2016
1,808

edits

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