A command line calculator, and F#/Fparsec learning project.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Art 966e0bee91
fix highlighting
5 months ago
.gitattributes fix highlighting 5 months ago
.gitignore fix highlighting 5 months ago
Program.fs fix highlighting 5 months ago
Readme.md proofread readme 5 months ago
fskalc fix parsing bug with implicit mult t 5 months ago
fskalc.fsproj fix parsing bug with implicit mult t 5 months ago
release.sh readme, build script update 5 months ago



  1. Have dotnet-sdk installed
  2. Go to the directory where fskalc is located
  3. Run dotnet restore to restore the obj/ directory
  4. Run dotnet run for debug run
  5. ./release.sh for release run, the binary will be found in bin/Release/net[version]/[platform]/publish/fskalc, and also will be copied to the active directory


The following is an informal overview of FSKalc's capabilties.


Number literal



Variable read



Will print an error message if variable is undefined. The ans variable implicitly refers to the result of the last expression statement.

Parentheses for precedence



Parentheses increase precedence.

Function calls

Functions are called with !.


sin! pi/2

Multile arguments need to be separated with commas.

logx! 5, 3

Arithmetic operators

The following operators are valid, in decreasing precedence:

  • ^ power; right associative
  • - unary negation; note that multiple negations next to eachother are invalid!
  • factor precedence:
    • * multiplication; left associative
    • / division; left associative
    • // integer (flooring) division; left associative
    • % modulo; left associative
    • if no binary operator is found, multiplication is assumed
  • term precedence:
    • + addition; left associative
    • - subtraction; left associative


Statements are the top level construct. Every line in an FSKalc program has to be a statement.

Expression statement

Any valid expression is also a valid statement. The result of expression statements is printed to the screen, and also assigned to the variable names ans.

Variable assignments

Variable assignments have the following syntax:

identifier = expression

Where the identifier is a string of characters containing only letters and underscores.

Existing variables or functions can be overwritten by new variables/functions.

Function declaration

Function declaration has the following syntax, demonstrated by an example below.

double x = x * 2

Multiple parameters need to be declared with commas separating.

sum x, y = x + y

Warning! as there are no scopes in FSKalc, passing arguments to functions will modify the global scope.


Builtin Constants

  • pi
  • tau (pi * 2)
  • e (euler's number)
  • inf (infinity)
  • nan (not a number)

Builtin Functions

  • sin, cos, tan - they take 1 argument, in radians
  • arcsin, arccos, arctan - they take 1 argument, they return in radians
  • sqrt - returns square root
  • log - logarithm base of 10
  • ln - natural logarithm
  • exp - returns e to the power of the argument
  • rtx - returns the xth root (1st argument: base, 2nd argument: val)
  • logx - returns the base x log (1st argument: base, 2nd argument: val)


Comments can be inside matching (*, *) parentheses.