Giter Club home page Giter Club logo

rpn's People

Contributors

philrunninger avatar

Stargazers

 avatar

Watchers

 avatar  avatar

rpn's Issues

Accept command line parameters.

The math problem to be solved can be entered on the command line, like so:

prompt$ rpn 6 7 *
42

In addition to printing the result, it is put into the paste buffer. This might/should also include separating the calculation engine from the UI.

The hard part will be the operators. Some will need to be escaped, which will put a damper on this even being user friendly.

Undo

Make it possible to undo operations to any prior state within the session.

Recognize registers without the `<` prefix

It would be easier to retrieve the stack values without having to type the < prefix, but this is the same way we invoke macros. Remove the < prefix, and keep the current way of invoking macros the same.

  • Remove the < prefix.
  • Remove then << prefix. Users will just have to do a cs foo instead of <<foo. That's a fair tradeoff, IMO.
  • >foo remains the same.
  • >>foo remains the same.

Make changing colors easier, and user configurable

Currently, changing the colors requires changes to the code. Given that different color schemes can cause undesirable looking calculator, there should be a better, configurable way to choose colors from the palette.

New way of handling bases

Use Javascript's way of handling numbers. From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types...

Integers

Integers can be expressed in decimal (base 10), hexadecimal (base 16), octal (base 8) and binary (base 2).

  • Decimal integer literal consists of a sequence of digits without a leading 0 (zero).
  • Leading 0 (zero) on an integer literal indicates it is in octal. Octal integers can include only the digits 0-7.
  • Leading 0x (or 0X) indicates hexadecimal. Hexadecimal integers can include digits (0-9) and the letters a-f and A-F.
  • Leading 0b (or 0B) indicates binary. Binary integers can include digits only 0 and 1.

Some examples of integer literals are:

  • 0, 117 and -345 (decimal, base 10)
  • 015, 0001 and -077 (octal, base 8)
  • 0x1123, 0x00111 and -0xF1A7 (hexadecimal, "hex" or base 16)
  • 0b11, 0b0011 and -0b11 (binary, base 2)

Add an edit command to edit the stack as a whole

This is kinda like a "Oops! I have a typo 23 numbers ago." remedy. It should present the existing stack as in initial value to be edited; otherwise, it's no better than cs followed by retyping the stack.

DEG> 12 3 4 5 6 7 8 9 10
12 3 4 5 6 7 8 9 10 DEG> edit
New Stack: 1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10 DEG> sum
sample=[1 2 3 4 5 6 7 8 9 10] ⋅ 55 DEG>

Create and run macros

Let the user write macros for commonly used or lengthy calculations, so they can be run quickly.

Attempting to write Infinity to JSON destroys the ~/.rpnrc file

Here is the sequence of operations that reproduce the error.

$ cat ~/.rpnrc
{
  "stack": [
    {
      "0": 1.0
    },
    {
      "0": 2.0
    },
    {
      "0": 3.0
    }
  ],
  "registers": {
  },
  "macros": {
  },
  "base": 0,
  "angle": "DEG",
  "colors": {
    "title": "green",
    "error": "light_red",
    "register": "yellow",
    "help_heading": "blue",
    "help": "light_blue"
  }
}
$ rpn
RPN Calculator, ©2016, Phil Runninger ═════════════════════ Enter ? for help.
1 2 3 DEG► 0 \
865: Infinity not allowed in JSON
1 2 3 Infinity DEG► <C-Z>
[1]+  Stopped                 rpn

At this point, I've put rpn in the background to look at the ~/.rpnrc file. It is empty. Then I bring rpn back to the foreground, where deleting the Infinity causes the ~/.rpnrc file to be written correctly.

JOBS philr2 ~/projects $ cat ~/.rpnrc
JOBS philr2 ~/projects $ fg
rpn
del
1 2 3 DEG►
═══════════════════════════════════════════════════════ Thanks for using rpn.
3 was copied to the clipboard.
$ cat ~/.rpnrc
{
  "stack": [
    {
      "0": 1.0
    },
    {
      "0": 2.0
    },
    {
      "0": 3.0
    }
  ],
  "registers": {
  },
  "macros": {
  },
  "base": 0,
  "angle": "DEG",
  "colors": {
    "title": "green",
    "error": "light_red",
    "register": "yellow",
    "help_heading": "blue",
    "help": "light_blue"
  }
}
$

Next time into rpn, I need to reconfigure my colors, base, and angle; and I've lost my stack, registers, and macros.

Allow Infinity to be stored in the JSON file, so it's not destroyed.

Truncate the stack (on screen only) when it gets too big

Change the display of the stack and multi-value registers to something like this before it starts wrapping on the screen.

{85 more} 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 DEG► sum
sample=[{90 more} 91 92 93 94 95 96 97 98 99 100] • 5050 DEG► 

An error causes the clipboard to not be set

To reproduce:

RPN Calculator, ©2016, Phil Runninger ═══════════ Enter ? for help.
DEG▶︎ 1 2 3 
1 2 3 DEG▶︎ asin
Numerical argument is out of domain - "asin"
1 2 3 DEG▶︎ <Enter>
═════════════════════════════════════════════ Thanks for using rpn.

Expected behavior is that 3 is put in the clipboard, but this doesn't happen.

Create an angle mode

The calculator should be able to switch between degrees and radians (the current fixed mode). This is not conversion, as is provided by deg>rad and rad>deg, but rather a persistent switch of mode. Once set to deg or rad, trig functions assume inputs to be in that mode or return angles in that mode.

Make settings permanent

Settings should be restored when a new calculator session is started. Some settings that come to mind:

  • Colors (see issue #2)
  • Angle mode
  • Base mode
  • Macros (see issue #4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.