Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
{def F {lambda {:n} {if {= :n 0} then 1 else {- :n {M {F {- :n 1}}}} }}}
|
||||
{def M {lambda {:n} {if {= :n 0} then 0 else {- :n {F {M {- :n 1}}}} }}}
|
||||
|
||||
{map F {serie 0 19}}
|
||||
-> 1 1 2 2 3 3 4 5 5 6 6 7 8 8 9 9 10 11 11 12
|
||||
{map M {serie 0 19}}
|
||||
-> 0 0 1 2 2 3 4 4 5 6 6 7 7 8 9 9 10 11 11 12
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
{def cache
|
||||
{def cache.F {#.new}}
|
||||
{def cache.M {#.new}}
|
||||
{lambda {:f :n}
|
||||
{let { {:f :f} {:n :n}
|
||||
{:cx {if {equal? :f MF}
|
||||
then {cache.F}
|
||||
else {cache.M}}}
|
||||
} {if {equal? {#.get :cx :n} undefined}
|
||||
then {#.get {#.set! :cx :n {:f :n}} :n}
|
||||
else {#.get :cx :n}}}}}
|
||||
-> cache
|
||||
|
||||
{def MF
|
||||
{lambda {:n}
|
||||
{if {= :n 0}
|
||||
then 1
|
||||
else {- :n {MM {cache MF {- :n 1}}}}}}}
|
||||
-> MF
|
||||
|
||||
{def MM
|
||||
{lambda {:n}
|
||||
{if {= :n 0}
|
||||
then 0
|
||||
else {- :n {MF {cache MM {- :n 1}}}}}}}
|
||||
-> MM
|
||||
|
||||
{MF 80}
|
||||
-> 50 (requires 55 ms)
|
||||
|
||||
{map MF {serie 0 100}} (requires75ms)
|
||||
-> 1 1 2 2 3 3 4 5 5 6 6 7 8 8 9 9 10 11 11 12 13 13 14 14 15 16 16 17 17
|
||||
18 19 19 20 21 21 22 22 23 24 24 25 25 26 27 27 28 29 29 30 30 31 32 32
|
||||
33 34 34 35 35 36 37 37 38 38 39 40 40 41 42 42 43 43 44 45 45 46 46 47
|
||||
48 48 49 50 50 51 51 52 53 53 54 55 55 56 56 57 58 58 59 59 60 61 61 62
|
||||
Loading…
Add table
Add a link
Reference in a new issue