Skip to content

Instantly share code, notes, and snippets.

@RelativisticMechanic
Last active August 8, 2023 20:25
Show Gist options
  • Save RelativisticMechanic/8a7d11306b2e6c7a4c8f3dccd1f52289 to your computer and use it in GitHub Desktop.
Save RelativisticMechanic/8a7d11306b2e6c7a4c8f3dccd1f52289 to your computer and use it in GitHub Desktop.
Flint Specification 0.0.1
Flint: A tiny alternative to excel for visualization and computation.
File Format:
---
ZIP -> sheet1.csv
sheet1.fl
Language
---
1. Arithmetic:
7 + 2;
8 * 5;
19.1 - 4;
25.4 / 2.8;
2.4 ** 2.1;
x * y + 6;
2. Variables
real x = 0;
real x = 2.5;
complex y = 1 + 2i;
complex y = 2.57 + 3.05i;
bool b = true;
bool b = false;
vec(3) v = [1,2,3];
mat(2,2) k = [2,3;4,1];
3. Math functions
sin(x)
cos(x)
tan(x)
cot(x)
sec(x)
csc(x)
abs(x)
exp(x)
sgn(x)
det(x)
inv(x)
hmt(x)
tnp(x)
cng(x)
log(base,x)
avg(x)
var(x)
cov(x,y)
stddev(x)
rand()
4. Matrix/Vector Addressing
mat(4,4) matrix = [1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1];
/* Return nth row */
row(matrix, n)
/* Return nth column */
col(matrix, n)
/* Return size of matrix, is a vec(2) */
vec(2) = matrix.length();
/* Return size of row */
real row_size = row(matrix, n).length();
/* Take certain element */
real m = matrix[n][m]
An nth vector is just a nx1 matrix.
5. Functions
matrix(4,4) Identity4(real scale)
{
matrix(4,4) result;
for(real i = 0; i < 4; i++)
{
result[i][i] = scale;
}
return scale;
}
matrix(4,4) new_mat = Identity4(1.0);
6. Loops
for & while.
for(init_statement; compare; increment)
{
/* Do Stuff */
}
while(comparison)
{
/* Do Stuff */
}
7. Addressing the table
/* Sets the first Price Column to 12.50 */
$TABLE["Price"][0] = 12.50;
Instead of strings you can also use indexing
$TABLE[1][0] = 0.0;
$TABLE[2][5] = 3.0 + 5i;
/* Called every time the table is loaded */
void OnTableLoad()
{
$TABLE["Total Amount"][0] = 0.0;
for(real i = 0; i < $TABLE["Goods"].length(); i++)
{
$TABLE["Total Amount"][0] += $TABLE["Goods"][i] * $TABLE["Qty"][i];
}
}
/* Can take and assign data using matrices and vectors as well */
matrix(8,8) matrix = $TABLE[0:8][0:8]
$TABLE[0:8][0:8] = matrix;
vec(5) v5 = $TABLE["Price"][0:5];
vec(7) v7 = $TABLE[3][0:7];
vec(8) vector8 = [1,2,3,4,5,6,7,8];
$TABLE["Price"][3:11] = vector8;
8. Plotting Charts
All plots will open new windows. For now, 2D plots only.
plot_id = plot(title, xlabel, ylabel, xmin, ymin)
scatter(id, x, y, color)
line(id, x, y, color)
bar(id, labels, freqs, color)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment