Package: pystacker
日本語  (Japanese)Stacker: An RPN Calculator and Extensible Programming LanguageStacker is a powerful Reverse Polish Notation (RPN) calculator built with Python, featuring basic mathematical operations and extensibility through plugins.InstallationPrerequisites:Ensure Python 3 is installed.Installation Options:Via pip:pipinstallpystackerFrom source:gitclonegit@github.com:remokasu/stacker.gitcdstacker
pythonsetup.pyinstallFeedback and ContributionsFeedback and contributions are welcome. Please submit issues or suggestions on theIssues page.DependenciesStacker uses external libraries like NumPy and Python Prompt Toolkit. Ensure these are installed:pipinstallnumpyprompt_toolkitUsageRun Stacker:stackerOr:python-mstackerStacker supports standard arithmetic operations (+, -, *, /) and advanced functions (sin, cos, tan, etc.). Users can input commands in RPN format and extend functionality using custom plugins.Input ExamplesStacker allows for straightforward RPN input. For example:Single-line input:stacker:0>34+[7]Multi-line input:stacker:0>3[3]stacker:1>4[3,4]stacker:2>+[7]Variables:syntax:value$namesetexample:stacker:0>3$xsetIn this example, we assign3tox.
If you input an undefined symbol, you need to prefix the symbol name with a dollar sign ($).From now on, when usingx, the character 'x' will be pushed onto the stack and evaluated to return3when popped.You can push the value of a symbol by prefixing it with @.For example,@xwill push3.stacker:0>3$xsetstacker:1>x[x]stacker:2>@x[x,3]stacker:1>+[6]Conditionals:ifsyntax:{true_block}{condition}ifexample:stacker:0>0$xsetstacker:1>{34+}{x0==}if[7]This example pushes7onto the stack becausexis equal to0.ifelsesyntax:{true_block}{false_block}{condition}ifelseexample:stacker:0>0$xsetstacker:1>{34+}{34-}{x0==}ifelse[7]This example pushes7onto the stack becausexis equal to0.Loops:dosyntax:start_valueend_value$symbol{body}doexample:stacker:0>010$i{iecho}do012345678910This example prints the numbers from 0 to 10.timessyntax:{body}ntimesexample:stacker:0>1{dup++}10times[1234567891011]In this example, we push 1 onto the stack and then repeat {dup (duplicate the top element) and ++ (add 1 to the top element)} 10 times.Define a function:syntax:(arg1arg2...argN){body}$namedefunexample:stacker:0>(xy){xy*}$multiplydefun
stacker:1>1020multiply[200]This defines a function namedmultiplythat takes two argumentsxandyand multiplies them together.Define a macro:syntax:{body}$namealiasexample:stacker:0>{2^3*5+}$calculatePowerAndAddaliasstacker:1>5calculatePowerAndAdd[80]This defines a macro with the body{2 ^ 3 * 5 +}and assigns it the namecalculatePowerAndAdd. This macro squares the number on the stack, multiplies it by 3, and then adds 5.Include ScriptsStacker scripts can be included in other scripts using theincludecommand. For example:stacker:0>"my_script.stk"includeAll functions, macros and variables defined in "my_script.stk" are added to the current stack.Running ScriptsStacker scripts can be created in *stk files. To run a script, simply execute it with Stacker. For example:my_script.stk:0$pset0100000$k{-1k^2k*1+/p+pset}do4p*psetpechoRunning the script:stackermy_script.stkCommand Line ExecutionYou can directly execute a specified RPN expression from the command line.stacker-e"3 4 + echo"Settingsdisable_plugin
Disable a specified plugin:stacker:0>"hoge"disable_pluginThis command deactivates thehogeoperator added as a plugin.
Note that it cannot be used on non-plugin oeratirs.disable_all_plugins
Disable all plugins at once.stacker:0>disable_all_pluginsenable_disp_stack
Enables the setting to display the stack contents each time. By default, this setting is already active.stacker:0>enable_disp_stackdisable_disp_stack
Sets the display of stack contents to be disabled. When this setting is enabled, only the latest element of the stack is displayed.stacker:0>disable_disp_stackdisable_disp_logo
Disables the display of the logo at startup.stacker:0>disable_disp_logoConfiguration FileYou can automatically load settings at startup. The configuration file should be placed in ~/.stackerrc. For example, if you write the following contents in ~/.stackerrc, the disable_disp_logo and disable_disp_stack will be automatically activated at startup.disable_disp_logo
disable_disp_stackCreating PluginsCreate custom plugins for Stacker using Python:In thepluginsdirectory, create a new Python file for your plugin (e.g.,my_plugin.py).stacker/
│
├── stacker/
│   ├── plugins/
│   │   ├── my_plugin.py
│   │   └── ...
│   │
│   ├── data/
│   ├── stacker.py
│   ├── test.py
│   └── ...
│
└── ...Adding your plugin here and reinstalling Stacker will apply the plugin permanently.Alternatively, create apluginsdirectory in the directory where Stacker is executed. This allows you to use plugins without reinstalling Stacker.Define required functions or classes in your plugin file.Add asetupfunction to register these with Stacker.Example:fromstacker.stackerimportStackerdeffunction(a,b):# Do somethingdefsetup(stacker:Stacker):stacker.register_plugin("command",function)Disabling PluginsUse operatorName disable_plugin to disable a specific plugin.Use disable_all_plugins to disable all plugins.DocumentationFor more detailed documentation, please refer tostacker/docs.Supported Operations+-*////%++--negbinoctdechexbandborbxor~>><<==!=<=<>=>eqnoqleltgegtechoprintandornot&&||^loglog2log10expsincostanasinacosatansinhcoshtanhasinhacoshatanhsqrtgcdlcmradians!ceilfloorcombpermabscbrtncrnprroundnroundrandrandintuniformdiceintfloatstrboolseqrangeminsummaxlendropdupswappickrotrotlinsertrevcleardispevalascchrconcattimeififelsetimesdosetdefunaliasinclude