X-mas calculater

remixed by frostybabe
See inside

Start by pressing a green flag. You can click the buttons on screen or use the keyboard: N="±", V="√", C="C", Z="AC", P=".", T="%", M="*", A="+", Q="?", D="/", S="-", E="=", L="MC", R="MR", I="M-", U="M+", Y="MS", X="X". (Scratch-programs can only use arrow-keys, 0-9, and a-z (and doesn't know shift-key status), except in answer-boxes where all characters can be typed.)

The question-mark-button "?" enters the program editor. You use the same symbols when programming as on the buttons on-screen, except that you use "*" and "/", and you can use "n" and "v" instead of "±" and "√". The programs are case-insensitive and unknown commands are ignored.

An example program computing √10 using Newton–Raphson method is stored (AC MC 1 M+ A0 10 / MR - MR / 2 M+ JT0 MR). Press Enter or click the OK-button to run the current program or type in a new.

The labels/anchors are A0 to A9 and there are five jump-commands: JU (unconditional), JT (true), JF (false), J+ (>=0), and J- (<0), e.g. JT0 goes to anchor A0 if the display is not close to zero (i.e. |display| > 9E-16).

You can select memory by using e.g. 7 MS (short for Memory Select). The M-commands then use memory 7. The default-memory is 0 and you can use as many memories as the Scratch Player allows. I believe this indirect addressing of memory together with the conditional jump-commands makes PocketCalc Turing-complete. You can eXchange the display with a hold-memory using X (similar to Sed).

You can call a subroutine/procedure/function if you precede a jump-command with _ e.g. _JU1. You can return from a subroutine using a jump with the special anchor/label ^ e.g. JU^. If you use ^ as a command it pops the return-stack but ignores the result. Actually _ pushes the program-counter to the return-stack.

There is a pause-command p that stops execution, to resume click ? and OK-button (or press Q and Enter). While pausing you can use the calculator as you normally would.

This example computes nCr (combination), e.g. possible poker-hands (5 cards) from 52 cards: 52 q
a2x0_ju3 1xmra1*x=x1m-mrjt1xju^
Enter 5 q Enter
Should show about 2598960.

Another example: Simpson's Rule compute the integral for y=2x^2+3x-1 in the interval 1 to 5 with 6 divisions: 6 q
Enter 5 q Enter 1 q Enter
Should show 114.66667.
You can change the integrand by editing between a1 and ju^.

Notes and Credits (added by frostybabe)


Shared: 19 Dec 2013 Modified: 25 Dec 2013
Favorite this project 0
Love this project 2
Total views 113
View the remix tree  53
More projects by frostybabe