Comments
Loading Dream Comments...
You must be logged in to write a comment - Log In
// Declare the GHOST;
£::DEMO:: // this segment;
£::MATHS:: // for sqrt();
£::UTILS:: // for sayget();
// There's no need to write "::MATHS::sqrt" or "::UTILS::sayget";
// because the system automatically searches the GHOST segments' symbol tables;
formula <:: &{ (a=%!1, b=%!2, c=%!3, x, y); // Declares the locals and unpacks the parameters;
x<:: (0 - b + sqrt (b ^ 2 - 4 * a * c)) $/ (2 * a);
y <:: (0 - b - sqrt (b ^ 2 - 4 * a * c)) $/ (2 * a);
( x , y ); // Return a vector of two values; }
main <:: &{ (a, b, c, result); // Declare the locals;
sayget ("What is the coefficient of x squared?", &a);
sayget ("What is the coefficient of x?", &b);
sayget ("What is the additive constant?", &c);
ttyout ("The results are ", formula (a, b, c), "displayed as a two element vector", CRLF); }