LastCalc: A powerful calculator meets Quora meets Siri

For the past month or so my main spare-time project has been a crazy idea called LastCalc (link at bottom).

I’ve been having trouble figuring out how to describe it, but here goes: Imagine a powerful web-based calculator that can answer your questions, a little like Google Calculator, Siri, or Wolfram Alpha, but where anyone can teach it how to calculate new things.

Additionally, rather than asking one question, you can ask a series of questions, each potentially referring to previous answers (programmers know this is a Read-Eval-Print-Loop or REPL).

Just like the others it supports basic math and unit conversions, like this (note: the highlighting is automatic and happens as you type – you type the bit before the big silver = and hit return, the answer appears after it):

But it goes a lot further. You can assign the result of a calculation to a variable, and then use it in subsequent calculations:

Internally LastCalc treats all numbers as rationals (x/y where x and y are integers) if possible, even if they are displayed as floating point numbers.  This means that it will not lose precision regardless of how many calculations you do (this can be a problem if using normal floating point numbers which are imprecise).

It’s not just simple numbers, LastCalc understands lists and associative arrays too, using a syntax very similar to JSON:

LastCalc is extensible, so if you find yourself repeating the same calculation over and over again, you can teach LastCalc how to do it (note: parameters are denoted by capitalization, like Prolog):

And it goes further, supporting pattern matching and recursion using these datastructures, just like languages like ML and Haskell:

Then use it with:

You can also pattern-match on maps.  Here I define a function that takes a map and returns a list of its keys:

Currently I’m working on a tutorial and help system so I don’t need to explain all of this before sending people to the site :-)

Right now you can only use functions that you define yourself, but in due course people will be able to share functions, much like they can share answers to questions with Quora.

So far it has only been tested in Chrome and Safari, and it definitely doesn’t work yet in Internet Explorer.  I’m waiting for the Javascript to stabilize before climbing that particular mountain.

Check it out at

It’s obviously a work in progress, if you’d like to follow discussion and provide me with feedback please join the LastCalc Google Group, or follow @LastCalc on Twitter.

5 thoughts on “LastCalc: A powerful calculator meets Quora meets Siri

  1. ian Post author

    Sammy, there isn’t, however there is no reason that one couldn’t be created. I recommend joining the discussion group to discuss further.

  2. CS

    A lot of this work may have already been done, you might want to check out the amazing Frink, first published in 2001 by Alan Eliasen. If you’re looking for a web front end, you might want to get in touch with him to see how it could be done.

    Here’s the docs (info also avail. at Wikipedia):

  3. ian Post author

    CS, thanks for the pointer, I wasn’t aware of Frink.

    Actually I may not have reinvented the wheel to the extent that you think I have – since all of the unit conversion in LastCalc is handled by the Java JScience library, which is very powerful.

    Frink doesn’t seem to be very well maintained from what I can tell, and to the extent that it supports programming, it seems to be an imperative language.

    With LastCalc I wanted to follow the functional programming approach, and in doing so I’ve borrowed quite a bit from languages like ML and Haskell (although LastCalc isn’t strongly typed).

    Thanks for bringing this to my attention though, I may be able to borrow some ideas from it.

  4. cpanel website hosting

    When I originally commented I clicked the “Notify me when new comments are added” checkbox and now
    each time a comment is added I get four e-mails with the same comment.
    Is there any way you can remove me from that service?


Leave a Reply

Your email address will not be published. Required fields are marked *