Suuga, math bot

What is this?

Playing with Suuga using Psi

Suuga is a simple math bot written by me in summer 2004. The main requirement I had for this project was to create a calculator that accepts expressions written like on a paper.

Bot is running at xmpp:suuga@uaznia.net

Suuga is written in Python, using PyXMPP library.

Name

I don't like acronyms (for example, because you need to hold Shift while typing them), so I took the efford to invent something more creative.

Suugaku means "math" in Japanese, so if we cut the ending, we'll get something that may sound a bit like a name of a beautiful Japanese math girl :) (yes, got a confirmation from Tokyo)

Assignment

Basic operation, or rather instruction, for this bot is... assignment instruction (yes, too much C++ in childhood)

For example, x = 5 assigns 5 to variable x. If there was no such variable, it is created. It's good to know that all expression has its value: it is the assigned value. Moreover, operator = is executed from right to left, so it is possible to cascade assignments: x = y = z = 5 or to use assignment as - for example - function argument: sin(x=5)

Operations

Number format

Exponential notation

12.3E-4 is equivalent to 12.3*10-4. Important: there must be capital E!

Base

a3.542cc#16 is a hex (16) number.

43.25#8E+10 is 43.25oct * 810

No * multiplication

Why would you use * on computer, if you don't need it on a paper?

However, e2 is a variable name

No braces in function calls

Again - more paper-like notation, for one-arguemnt functions. Argument may be an expression (even assignment), as long as it contains no spaces (exceptions a bit later):

There are two exceptions: function call as the argument and braces inside the argument:

Commands

!help
help message
!list
list of variables
!list sysfun
list of built-in functions

Source

*Download suuga-0.1.3.tar.gz