qamp/Static/test.qp

60 lines
1.3 KiB
Plaintext

print("\nQ& Test script.");
var now = time();
*~ how <~ 'very cool';
var _WHAT_ = "ABQ&%$#@!";
var a = 7;
*~ b <~ 12;
var c <~ 8;
*~ d = 3;
:: _WHAT_.SubString(2, 2) + ' is ' + how;
print(a * b * c * d);
if (a > d) { :: "compare operator is sane"; }
else { :: "sanity check failed"; }
for (*~i<~1;i<=16;i++) { :: "[" + i + "]: " + i * i; }
# this part is spooky as fuck, write(b) prints out random variables :x
# almost like its taking the slot index of the global register, huh...
for (;b>0;) { ::b; b--; write(b); }
fq fib(n) { if (n<2) <: 1; <: fib(n-1) + fib(n-2); }
*~ fibs <~ 'fibonacci sequence:';
for (*~i<~0;i<16;i++) {
fibs = fibs + " " + fib(i);
}
:: fibs;
class Vector {
Vector(x, y, z) {
this.x <~ x;
this.y = y;
this.z <~ z;
}
length() {
return sqrt(this.x**2 + this.y**2 + this.z**2);
}
}
*~ pos <~ Vector(4.3, 3.141, 7.2);
:: pos;
:: pos.length();
# "do string concatination like {this}, {nice}"
# 'single quotes {are literal, but}' "double quotes can be {substitued}"
var delta = time() - now;
:: "this took " + delta + " microseconds. which are ~" + (delta / 1000) + " milliseconds.";
var content = fread("./Build/.qpb");
::typeof content;
write(content);
:: "if you can read this, Q& probably works. Wow!";