Entropy/Narcissist: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with "{{draft task}} Write a program that computes and shows its own entropy. =={{header|Perl 6}}== <lang Perl 6>say log(2) R/ [+] map -> \p { p * -log p }, $_.bag.values »/» +...")
 
m (link to parent task)
Line 1: Line 1:
{{draft task}}
{{draft task}}


Write a program that computes and shows its own entropy.
Write a program that computes and shows its own [[entropy]].


=={{header|Perl 6}}==
=={{header|Perl 6}}==

Revision as of 07:01, 26 February 2013

Entropy/Narcissist is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Write a program that computes and shows its own entropy.

Perl 6

<lang Perl 6>say log(2) R/ [+] map -> \p { p * -log p }, $_.bag.values »/» +$_

   given slurp($*PROGRAM_NAME).comb</lang>
Output:
4.98893170929151