Evan Martin (evan) wrote in evan_tech,
Evan Martin

all i have to talk about is schoolwork these days

Man, this is ugly. Multiplication is implemented recursively as repeated addition, then exponentiation on top of that as repeated multiplication. But it works! And type-checks! Give it two integers and it gives you n^m.

Sadly, recursive functions mean that it's no longer guaranteed to terminate.
(fn n:int.
  (rec pwr:int->int m.
    (if m > 0 then
      (rec mul:int->int y.
        (if y > 0 then
          n+(mul (y + (-1)))
      ) (pwr (m + (-1)))
I was about to rewrite in in Python just for fun, but then I realized you can't (?) make recursive functions with Python lambdas.

  • memcache job offers

    I get occasional recruiter spam that specifically calls out "my work on memcached". This is pretty funny because all I did was make some trivial…

  • application stack

    "Put yourself in 1995. I'm going to tell the you of 1995 that in 2010, there will be a software platform with the following properties:" Luis Villa…

  • bsd license advertising

    Did you know that the 3-clause BSD (that is, the one with the "advertising" clause stripped) license still has an advertising requirement? Read it…

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.