Saturday, January 11, 2020

A calculator for the Terminal that renders beautiful math

 ───────────────────────────────────────────────────────────── Kary Nota ────── ┌────────────────────────────────────────────────────────────────────┐ │ │ │ 1 │ │ ─── │ │ 2 2 ⎜ e ⎟ │ │ In[1]: ───── + ───────────────────────────────────── + ⎜ ─── ⎟ │ │ 3 _______________________________ ⎣ 2 ⎦ │ │ ╱ ┌ π ┐ 2 ┌ π ┐ 2 │ │ ╱ Sin │ ─── │ + Cos │ ─── │ │ │ ╲╱ └ 2 ┘ └ 2 ┘ │ │ │ │ │ │ Out[1]: 3.1666666666666665 │ │ │ ├───────────────────────────────────────────────────────┬────────────┘ Nota is a powerful terminal calculator with rich │ mathematical notation and chart rendering. It gives │ you a beautiful language that is readable and easy to │ type and then renders your input into a beautiful │ notation with result └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ┌────────────────────────────────────────────────────────┐ │ │ │ In[2]: ⟨Earth's Radius⟩ ≡ 6371 │ │ │ │ Out[2]: 6371.0 │ │ │ │ │ │ 4 3 │ │ In[3]: ⟨Earth's Volume⟩ ≡ ─── × π × Earth's Radius │ │ 3 │ │ │ │ Out[3]: 1.0832069168457535e12 │ │ │ └──────────────┬─────────────────────────────────────────┤ Nota's Language offers beautiful ideas │ in its design; such as having variables │ that accept spaces and apostrophe └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ ┌──────────────────────────────────────────────────────────────────┐ │ First you should have GNU Make and Haskell Stack installed. Then │ │ you have to run these commands within your terminal to install │ │ nota. This will give you the command nota that you can run: │ └──┬──────────────────────────────────────────────┬────────────────┘─ ─ ┐ │ git clone http://codes.kary.us/nota/nota.git │ Installation │ cd nota ├ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ │ make install │ └──────────────────────────────────────────────┘ ┌──────────────────┐ │ Language Grammar │ └────┬─────────────┘ │ ├───────────────────────────────────────────────────┐ Grammar Component │ Description │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┼───────────────────────────────────────────────────┤ Normal Numbers │ Numbers in Nota can be in the normal form. │ │ Integer form like 0 or 42480. And in the decimal │ │ form like 1.8402 or 0.5 but remember decimal only │ │ numbers cannot be without zero: so 0.5 is │ │ possible but .5 is not. │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┼───────────────────────────────────────────────────┤ Hex Number │ Hexadecimal Numbers are supported and must be │ │ started with the 0x sign. So 0xfff is a number as │ │ well as 0x123. │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┼───────────────────────────────────────────────────┤ Names │ Nota approaches identifiers much differently than │ │ any other language. In Nota identifiers can have │ │ space within them, so no more camelCase, │ │ PascalCase, --kebab-case, what_ever; You can │ │ simply write things like size of the planet and │ │ it works. │ │ │ │ Also to make it more interesting, Nota even gives │ │ you ' (apostrophe) and therefore you can have │ │ things like radius of earth or earth's radius. │ │ │ │ Numbers are also allowed (but not for the first │ │ letter). You can have names like: X5 or X 5 and │ │ etc. │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┼───────────────────────────────────────────────────┤ Binary Operator Binary operators in Nota are: +, -, *, /, ^, %, │ │ ?, and !. They are fully explained in the Binary │ │ Operators section of the Language Reference. │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┼───────────────────────────────────────────────────┤ Negation │ The only unary operator that Nota defines is the │ │ value negation - operator. E.g: -13 + -sin[x]. │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┼───────────────────────────────────────────────────┤ Parenthesis │ Nota provides the parenthesis notation to reorder │ │ precedence like: (1 + 2) * 3. │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┼───────────────────────────────────────────────────┤ Parenthesis │ Functions in Nota are written not with │ │ parenthesis but with brackets (Sin[x], Log[2, │ │ 100], ...). │ │ │ │ Just like identifiers they are case insensitive │ │ so it doesn't matter how you write them: log[x] = │ │ LOG[x] = lOG[x] │ │ │ │ For the sake of beauty, some of the functions are │ │ rendered specially (explained in the Notational │ │ Functions section). Also in the reference you can │ │ find a full explanation of the functions. │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┼───────────────────────────────────────────────────┤ Name Assignment │ You can assign names to calculations for further │ │ use. These names are constants and you have to │ │ use the assignment grammar to register them. Name │ │ = Value. So something like: Earth's Volume = 3/4 │ │ * pi * Earth's Radius^3. │ └───────────────────────────────────────────────────┘ ┌────────┐ │ help │───┐ └────────┘ │ │ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ │ ┌──────────────────────────────────────────┐ Control Commands └──▶│ Shows you the link to the documentations │ └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ └──────────────────────────────────────────┘ ┌─────────────────────────────┐ ┌────▶│ Exists from the application │ ┌────────┐ │ └─────────────────────────────┘ │ exit │────┘ ┌──────────────────────────────┐ └────────┘ ┌─────▶│ Clears the calculator screen │ │ └──────────────────────────────┘ │ ┌─────────┐ │ │ clear │─────┘ └─────────┘ ┌─────────────────────────────┐ │ Binary Operators │ ┌ ─ ─ ─ ─ ─ ┼────────────────┬────────────┴────────┐ │ │ │ │ 1 + 2 │ In[1]: 1 + 2 │ Summation │ │ │ │ ├ ─ ─ ─ ─ ─ ┼────────────────┼─────────────────────┤ │ │ │ │ 1 - 2 │ In[2]: 1 - 2 │ Subtraction │ │ │ │ ├ ─ ─ ─ ─ ─ ┼────────────────┼─────────────────────┤ │ │ │ │ 1 * 2 │ In[3]: 1 × 2 │ Multiplication │ │ │ │ ├ ─ ─ ─ ─ ─ ┼────────────────┼─────────────────────┤ │ 1 │ │ │ 1 / 2 │ In[4]: ─── │ Division │ │ 2 │ │ ├ ─ ─ ─ ─ ─ ┼────────────────┼─────────────────────┤ │ 2 │ │ │ 1 ^ 2 │ In[5]: 1 │ Power │ │ │ │ ├ ─ ─ ─ ─ ─ ┼────────────────┼─────────────────────┤ │ │ │ │ 1 % 2 │ In[6]: 1 % 2 │ Modulo │ │ │ │ ├ ─ ─ ─ ─ ─ ┼────────────────┼─────────────────────┤ │ │ │ │ Returns 1 if │ 1 ? 2 │ In[7]: 1 = 2 │ Equals │ ●───┤ equals and 0 │ │ │ │ otherwise ├ ─ ─ ─ ─ ─ ┼────────────────┼─────────────────────┤ │ │ │ │ Returns if not │ 1 ! 2 │ In[8]: 1 ≠ 2 │ Equals │ ●───┤ equals and 0 │ │ │ │ otherwise └ ─ ─ ─ ─ ─ ┴────────────────┴─────────────────────┘ ▲ ▲ ▲ │ │ │ ┌────────┘ │ ┌─────┘ │ └───────┐ │ └── What to write │ │ │ └── What it does │ How it'll look ──┘ ┌───────────────────────┐ │ Notational Functions │ ┌──────────────────┬────────────────┬─────────┴──────┬────────────────┤ │ sqrt[1/2] │ abs[1/2] │ floor[1/2] │ ceil[1/2] │ ├──────────────────┼────────────────┼────────────────┼────────────────┤ │ _____ │ │ │ │ │ ╱ 1 │ ⎢ 1 ⎥ │ ⎜ 1 ⎟ │ ⎡ 1 ⎤ │ │ In[1]: ╱ ─── │ In[2]: ⎢ ─── ⎥ │ In[3]: ⎜ ─── ⎟ │ In[4]: ⎢ ─── ⎟ │ │ ╲╱ 2 │ ⎢ 2 ⎥ │ ⎣ 2 ⎦ │ ⎢ 2 ⎥ │ │ │ │ │ │ └──────────────────┼────────────────┼────────────────┼────────────────┤ │ │ │ │ Square Root ● Absolute ● Floor ● Ceiling ● • In[1]: 5 • 8 • ┌─────┬─────┐ Out[1]: │ 5.0 │ 8.0 │ └─────┴─────┘ ┌──────────────────────────────────┐ In[2]: 10 │ Out[] function makes it possible │ │ to access the history of your │ Out[2]: 10.0 │ calculations. To get output no. │ │ "x", you can can simply use: │ │ out[x] and access it │ ┌ ┐ ┌ ┐ └────────────────┬─────────────────┼───▶ In[3]: Out │ 1 │ + Out │ 2 │ │ The Special │ └ ┘ └ ┘ │ Out[] Function │ └─────────────────┘ Out[3]: 15.0 ────┐ ● │ │ │ │ │ Log[x] ──┼── Logarithm of x of base e │ │ │ Log[b, x] ──┼── Logarithm of x of base b │ │ │ Sin[x] ──┼── Sine of x │ │ │ Cos[x] ──┼── Cosine of x │ │ │ Tan[x] ──┼── Tangent of x │ │ │ Cot[x] ──┼── Cotangent of x │ │ │ Sec[x] ──┼── Secant of x │ │ │ Csc[x] ──┼── Cosecant of x │ │ │ Asin[x] ──┼── Area Sine of x │ │ │ Acos[x] ──┼── Area Cosine of x │ │ │ Atan[x] ──┼── Area Tangent of x │ │ │ Sinh[x] ──┼── Hyperbolic Sine of x │ │ │ Cosh[x] ──┼── Hyperbolic Cosine of x ├──── Functions │ │ Tanh[x] ──┼── Hyperbolic Tangent of x │ │ │ Coth[x] ──┼── Hyperbolic Cotangent of x │ │ │ Sech[x] ──┼── Hyperbolic Secant of x │ │ │ Csch[x] ──┼── Hyperbolic Cosecant of x │ │ │ Asinh[x] ──┼── Hyperbolic Area Sine of x │ │ │ Acosh[x] ──┼── Hyperbolic Area Cosine of x │ │ │ Atanh[x] ──┼── Hyperbolic Area Tangent of x │ │ │ Max[a, ..., b] ──┼── Maximum of the argument │ │ │ Min[a, ..., b] ──┼── Minimum of the argument │ │ │ Sum[a, ..., b] ──┼── Arguments sum │ │ │ Exp[x] ──┼── Natural exponent to the power of x │ │ │ │ │ ● │ ────┘ ┌────────────────────────────────┐ ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┤ Identifiers with Reserved │ ___ │ Notation │ │ 1 + ╲╱ 5 ├─────────────────────────┬──────┘ In[1]: ⟨φ⟩ ≡ ─────────── │ For a more beautiful │ │ 2 │ rendering, Nota │ │ reserves some │ │ Out[1]: 1.618033988749895 │ identifiers to be used │ │ for rendering famous │ │ │ characters out of a │ In[2]: φ │ normal keyboard. Expect │ │ │ for the Pi, every other │ Out[2]: 1.618033988749895 │ identifier is available │ │ │ to be declared │ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─│ │ ├─────────────────────────┘ │ │ │ ▼ Alpha' │ Alpha │ Beta' │ Beta │ Chi' │ Chi │ Delta' │ Delta │ E ● ───────┼───────┼───────┼──────┼──────┼─────┼────────┼───────┼──── │ Α │ α │ Β │ β │ Χ │ χ │ Δ │ δ │ e │ │ │ Epsilon' │ Epsilon │ Eta' │ Eta │ Gamma' │ Gamma │ Iota' │ Iota │ ─────────┼─────────┼──────┼─────┼────────┼───────┼───────┼─────── │ Ε │ ε │ Η │ η │ Γ │ γ │ Ι │ ι │ │ │ Kappa' │ Kappa │ Lambda' │ Lambda │ Mu' │ Mu │ Nu' │ Nu │ Omega' │ ───────┼───────┼─────────┼────────┼─────┼────┼─────┼────┼───────── │ Κ │ κ │ Λ │ λ │ Μ │ μ │ Ν │ ν │ Ω Mapping │ │ │ Omega │ Omicron' │ Omicron │ Phi' │ Phi │ Pi' │ Pi │ Psi' │ Psi │ ──────┼──────────┼─────────┼──────┼─────┼─────┼────┼──────┼────── │ ω │ Ο │ ο │ Φ │ φ │ Π │ π │ Ψ │ ψ │ │ │ Rho' │ Rho │ Sigma' │ Sigma │ Tau' │ Tau │ Theta' │ Theta │ ─────┼─────┼────────┼───────┼──────┼─────┼────────┼──────── │ Ρ │ ρ │ Σ │ σ │ Τ │ τ │ Θ │ θ │ │ │ Upsilon' │ Upsilon │ Xi' │ Xi │ Zeta' │ Zeta ● ─────────┼─────────┼─────┼────┼───────┼─────── Υ │ υ │ Ξ │ ξ │ Ζ │ ζ ──────────────────────────────────────────────────────────────────────────────── Copyright 2018-present by Pouya Kary. All Rights Reserved. 


from Hacker News https://kary.us/nota/

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.