Bringing this back to the real world, did someone say imperative?  Lets try
declarative for a change :)

import math._
val phi = (1+sqrt(5))/2.0d
def fib(n: Int) = round(pow(phi,n)/sqrt(5))

(0 to 10) map (fib)
// = Vector(0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55)

I would have used BigDecimal for accuracy, but that would need me to use
JScience or equivalent or roll my own pow, sqrt, and round functions - a
bit overkill for such a simple example!

Rest assured that +, /, etc. work just fine for BigDecimals in Scala, and
therein lies the real power of the language; the stuff that should be
simple remains so, unhindered by boilerplate.


On 9 February 2012 20:16, clay <[email protected]> wrote:

> I stand corrected. I didn't see that before. People are supposed to be
> initially skeptical about this kind of thing. Here is the link he is
> referring to:
>
> http://youtu.be/6RwrT6N43lY
>
> On Feb 9, 11:49 am, Simon Ochsenreither
> <[email protected]> wrote:
> > > This is way too scripted and the childish exuberance is too calculated
> to
> > > not be done by an adult
> >
> > You mean like the scripted live presentation in front of an audience with
> > completely scripted questions?
> >
> > Sometimes I really wonder why I'm still reading this mailing list...
>
>

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to