Add a bunch of new languages

This commit is contained in:
Ingy döt Net 2013-04-09 00:31:41 -07:00
parent 1e05ecd7ee
commit 2a4d27cea0
158 changed files with 1469 additions and 0 deletions

View file

@ -0,0 +1,17 @@
#lang racket
(require math)
(define (log2 x)
(/ (log x) (log 2)))
(define (digits x)
(for/list ([c (number->string x)])
(- (char->integer c) (char->integer #\0))))
(define (entropy x)
(define ds (digits x))
(define n (length ds))
(- (for/sum ([(d c) (in-hash (samples->hash ds))])
(* (/ d n) (log2 (/ d n))))))
(entropy 1223334444)