The awesomeness of ZEL part 2.

10:00AM Apr 23, 2016 in category General by Zoltan Farkas

:Since I started ZEL to calculate fibonacci for the PART 1 article, I have added some extra info about the result of a operation

ZEL Shell
zel>func det fib(x) { fib(x-1) + fib(x-2) }
result>zel_0
type>class org.spf4j.zel.vm.Program
executed in>6889844 ns
zel>fib(0) = 0
result>0
type>class java.lang.Integer
executed in>4319632 ns
zel>fib(1) = 1
result>1
type>class java.lang.Integer
executed in>317251 ns
zel>fib(30)
result>832040
type>class java.lang.Integer
executed in>50519054 ns
zel>fib(50)
result>12586269025
type>class java.lang.Long
executed in>5201067 ns
zel>fib(100)
result>354224848179261915075
type>class java.math.BigInteger
executed in>7518551 ns
zel>fib(101)
result>573147844013817084101
type>class java.math.BigInteger
executed in>572010 ns
zel>

As you might notice there are 2 "strange" things to observe: 

  1. The result types are different. Thanks to ZEL's type auto upgrade feature. (no overflows in ZEL)
  2. Execution time for fib(101) < execution time for fib(100), and this is thanks to the "det" (deterministic) keyword used to declare the fibonacci function.

For more detail please see 

Comments[0]

Comments:

Post a Comment:
Comments are closed for this entry.