4 ms·
> 5. `qalc` from libqalculate: https://github.com/Qalculate/libqalculate https://github.com/Qalculate/libqalculate Or, you know, any REPL available.
by rootlocus 6y ago
> 5. `qalc` from libqalculate: https://github.com/Qalculate/libqalculate https://github.com/Qalculate/libqalculate
Or, you know, any REPL available.
- alpaca128 6y agoOr a simple `=() { bc -l <<< "scale=10;$1" }` in the usual bash file and you can use bc to do calculations by starting with a =. Just a little shortcut but REPLs like Python's take a while to spin up, so it's pretty convenient.
- xorcist 6y agoThat's a nifty idea! Maybe without lower scale and with the semicolon: = () { bc -l <<< "$*"; } "Stealing" the equals sign for this purpose feels a bit risky, but maybe it isn't.
- JNRowe 6y agoI'd guess that xorcist added a space at the end of the function name because zsh uses =( to specify one type of process substitution. Without the space or an escape for = zsh will error on alpaca128's definition believing you wanted something else entirely. To that point zsh has some excellent additions for process substitution beyond bash's <(list), but it also makes for yet more weird incompatibilities for when that matters. I only looked at this to start with because I assumed the space was because =() would have been treated as the full path modifier for a command called (), because it would mean that with any other character including other bracket types. TIL.
- deadbunny 6y ago> Just a little shortcut but REPLs like Python's take a while to spin up, so it's pretty convenient. Really? Loading python takes basically 0 seconds for me... the slowest I could get running `time python3` and hitting ctrl-d (to exit) is like 0m0.104s.
- stjohnswarts 6y agopython comes up in way less than a second on my old mac air?
- enriquto 6y agomy favourite is pari/gp, that can be used as a simple calculator, but also has quite fancy math at your fingertips. For example, it is the easiest way to compute entire series: you type "exp(sin(x))" and you get "1+x+1/2*x^2-1/8*x^4-1/15*x^5 ..."
- JNRowe 6y agoIt isn't shown in TFA, but the zcalc keymap is bindable in the line editor so not only can you use it like qalc/irb/luap/whatever you can also take advantage of any other functionality of zsh within it. Admittedly, you could do some of that with some magic $if/$endif guards in your ~/.inputrc if your REPL uses readline, but the integration is nice functionality if you're a heavy zsh user. I think of it more like the expression register in vim or eval-print-expression in emacs.