How old is Adaline?

What would the following haskell code print?

1
2
3
4
5
6
7
current_year = 2015   
andy_birth = 1984   
andy_minus_adaline = 4   
adaline = andy - andy_minus_adaline   
andy = current_year - andy_birth   

main = putStrLn $ show adaline


Bonus: How does a similar piece of code behave in each of Python ? What about Mathematica?

Inspiration: Calvin's Problem

1998 31 Error 27

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

If you have read the solution here , you might be thinking what the difference between that code and this code is.

There isn't. The difference is in the paradigm of programming: Haskell and Mathematica are functional languages where = is actually a definition, not an assertion.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...