shikipl

0.1.1 • Public • Published

ShikiPL

ShikiPL computes mathematical formulae written by ASCII art.
ShikiPL translates ASCII art to JavaScript code.

Install

To install ShikiPL, type the command shown as follows.

$ npm install -g shikipl

How to use

A ShikiPL code which you want to bury in JavaScript is written in \[...\] block.

var f = \[
a = 1

         2
f(x) = 2x  + 1
\]

In above example, the variable f has two properties.
One of property is a, which is a constant value 1, and another property is f which is a function with argument x.

You can use object which is generated by ShikiPL by shown as follows.

console.log(f.f(2));  // outputs 9

To translate ShikiPL to JavaScript, executes the command shown as follows.

$ shikipl filename.js.shikipl

Example

Simple formula

var f = \[
         2
f(x) = 2x  + 1
\]
console.log(f.f(2));  // outputs 9

Fraction

var f = \[
        x + 1
f(x) = -------
          2
\]
console.log(f.f(1));  // outputs 1

Square root: a solution of quadratic equation

var f = \[
                     ________
                    / 2
              -b + v b  - 4ac
f(a, b, c) = -----------------
                     2a
\]
console.log(f.f(2, -4, 2));  // outputs 1

Trigonometric function

var f = \[
f(a) = sin a
\]
console.log(f.f(Math.PI / 2));  // outputs 1

Power of trigonometric function

var f = \[
          2        2
f(a) = sin  a + cos  a
\]
console.log(f.f(8.765346283));  // outputs 1

Logarithm

var f = \[
f(a) = log a
\]
console.log(f.f(Math.E));  // outputs 1

Logarithm with base

var f = \[
f(a) = log  a
          2
\]
console.log(f.f(8));  // outputs 3

Document

A document of ShikiPL is here.

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i shikipl

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

57.4 kB

Total Files

9

Last publish

Collaborators

  • ymoriguchi