parser: regenerate with lambda
[nit.git] / examples / rosettacode / fibonacci_word.nit
1 #!/usr/bin/env nit
2 #
3 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # This program is public domain
5
6 # Task: Fibonacci_word
7 # SEE: <http://rosettacode.org/wiki/Fibonacci_word>
8 module fibonacci_word
9
10 import counter
11
12 var words = new Array[String]
13 words[0] = ""
14 words[1] = "1"
15 words[2] = "0"
16
17 for i in [1..37] do
18 var w
19 if i >= words.length then
20 w = words[i-1] + words[i-2]
21 words[i] = w
22 else
23 w = words[i]
24 end
25 var out = w
26 if w.length > 40 then out = "..."
27 print "{i}\t{w.length}\t{w.chars.to_counter.entropy.to_precision(16)}\t{out}"
28 end