Coder Social home page Coder Social logo

matrepl's Introduction

MatRepl

  • is a Matrix
  • and a repl: Read–Eval–Print Loop, where Print is doing operations on vectors and matrices in a graphic environment
  • written in vanilla javascript (ES6)
  • see live at https://matrepl.net

add 2 vectors

The repl has the following syntax (It's work in progress, new capabilities will be added)

  • arithmetic expressions:

    • add(+), subtract(-), divide(/), multiply(*) on scalars, vectors and matrices.
  • variable declaration eg: a = 1 + 2

  • remove(x) removes bindings (when it's an object (eg vector), removes it from the matrix)

  • remove(@n) removes an object using it's assigned index (n is a number)

    • By the way, values can be bound to a name (assigned to a variable), but you can always also refer to them using their id, using : @n
    • so a = vector(1,1)

    > vector@0{x0:0, y0: 1, x:1, y:1}

    • and then @0

    > vector@0{x0:0, y0: 1, x:1, y:1}

  • method calls: a = vector(12, 1) works as well. The start is now the origin.

    > vector@0{x0:0, y0: 2, x:12, y:1}

    vector(-1 -1) != vector(-1-1) and the latter would mean vector(-2) which is not legal.

  • arrays: [i0, i1, i2, ... in] creates an array.

    • [i0, i1] is special: it is a shorthand for creating a 2-dimensional vector. I'll have to think of another way to create an array of length 2...
  • ```id()`` adds a 2d identity matrix, which is also the two basis vectors.

  • properties

    • a = [1,2]
    • a.type

    > vector

    • a.x+1

    > 13

  • drag vectors using the mouse pointer. You can change the vector arrows visually

  • lazy evaluation. The difference between c = a+b and c = "a+b" is that the latter assigns to c a parsed expression that can always be evaluated later. When you apply lazy evaluation and later update a, the value for c will be reevaluated automatically. Combined with vector dragging, this way you can get an intuition for vector addition. Want to do the same for matrix multiplication and basis change.

  • Example: enter the following, like in the screenshot:

    a = vector(0.5, 0.5)
    b = vector(-1, 1)
    c = "a + b"
    
  • and press enter. Then using the mouse pointer move vector a or b. Or try: a = 2 * a This updates vector a to twice it's size. And, because c is defined lazily, it is updated as well!

To run locally

  • make sure you have node/npm
  • cmdline: npm run start
  • and enter help()

matrepl's People

Contributors

shautvast avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.