Q-Graph 1.4 review

Download
by rbytes.net on

Q-Graph is a collection of Q scripts that provide a graph data structure and a full-featured graph editor (the latter requires Tcl/Tk

License: GPL (GNU General Public License)
File size: 0K
Developer: Albert Graef
0 stars award from rbytes.net

Q-Graph is a collection of Q scripts that provide a graph data structure and a full-featured graph editor (the latter requires Tcl/Tk).

Q-Graph library can be used to implement and test graph algorithms using the Q language.

Q is a functional programming language based on term rewriting. Thus, a Q program or "script" is simply a collection of equations which are used to evaluate expressions in a symbolic fashion.

The equations establish algebraic identities and are interpreted as rewriting rules in order to reduce expressions to "normal forms".

For instance, here is how you define a function sqr which squares its argument by multiplying it with itself:
sqr X = X*X;

Note that, as in Prolog, capitalized identifiers are used to indicate the variables in an equation, which are bound to the actual values when an equation is applied. Equations may also include a condition part, as in the following definition of the factorial function:

fact N = N*fact (N-1) if N>0;
= 1 otherwise;

Functions on structured arguments are defined by "pattern matching". E.g., the product of a list (denoted in Prolog-like syntax) can be computed with these two equations:

prod [] = 1;
prod [X|Xs] = X*prod Xs;

With this definition, the factorial can now also be defined as follows (the notation [1..N], as in Haskell, denotes an arithmetic sequence):

fact N = prod [1..N];

As you can see, the definitions are really just like mathematical equations. The syntax is superficially similar to other modern functional languages like Miranda and Haskell, except that Q is "free-format", i.e., it does not use layout to indicate syntactical structure (thus the semicolon is used to terminate an equation).

Due to its term rewriting heritage, Q goes well beyond most other functional languages in that it also allows you to perform computations with symbolic expressions. For instance, with the definition of the sqr function from above, you will find that sqr (X+1) evaluates to (X+1)*(X+1). This might first look like an arcane feature, but it is actually quite useful, because you can try your definitions with symbolic inputs, too.

Q-Graph 1.4 keywords