Skip to content

Instantly share code, notes, and snippets.

@kbiedrzycki
Created September 5, 2016 16:32
Show Gist options
  • Save kbiedrzycki/12cd7e1e67d5aba8109b2adb34fd6600 to your computer and use it in GitHub Desktop.
Save kbiedrzycki/12cd7e1e67d5aba8109b2adb34fd6600 to your computer and use it in GitHub Desktop.
Example math expressions
// valid math scripts
// Example 1
x = 10 // this is mathjs variable, not plain JS
for (i = 0; i < x; i++) {
if (x >= 10) {
sin(x * pi) // mathjs sin function, pi is mathjs constant
}
}
// Example 2
a = range(1, 10, 0.5) // range creates mathjs matrix with values from 1 to 10, with 0.5 step
for (k = 0; k < a.size(); k++) { // size is mathjs function which returns size of an mathjs matrix
a[k] = a[k] * 10
}
// Example 3
// blocks if/else/for/while do ... end could also be valid if possible, and maybe easier to achieve?
for (j = 0; j < 10; j++) do
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment