DeWitt Clinton ’98 is a fan of Fibonacci functions and other simple examples for evaluating computer languages.

You can tell a *lot* about how a language works by looking at those simple examples. Does it encourage and/or optimize for tail-recursion? Does the language use strong typing / type annotations / type inference? Parameter pattern matching? Does it feel functional vs. imperative? Compare a Fibonacci implementation in Lisp to ML to C to Java to Scala and the differences are immediately apparent.

Indeed. DeWitt gives some fun examples but, for some reasons, fails to use R. Here is one (modified from this.):

> fib <- function(n){if(n <= 2) {if(n >= 0) 1 else 0 } else fib(n-1) + fib(n-2)}
> fib(10)
[1] 55
>

I think that this could be made slightly tighter and more elegant. Suggestions?

In a few years, every class at Williams that uses statistics will use R. The best professors have already switched over. Why haven’t you?

Facebooktwitter
Print  •  Email