Content deleted Content added
Tag: Reverted |
Tag: Reverted |
||
Line 85:
</syntaxhighlight>
Pure has efficient support for vectors and matrices (similar to that of [[MATLAB]] and [[GNU Octave]]), including vector and matrix comprehensions.
Namespaces, types and interfaces belong to the standard repertoire:
<syntaxhighlight lang="q">
nonfix nil;
type bintree nil | bintree (bin x left right);
outfix « »;
namespace foo (« »);
infixr (::^) ^;
x^y = 2*x+y;
namespace;
interface stack with
push s::stack x;
pop s::stack;
top s::stack;
end;
type stack [];
push xs@[] x | push xs@(_:_) x = x:xs;
pop (x:xs) = xs;
top (x:xs) = x;
</syntaxhighlight>
As a language based on [[term rewriting]], Pure fully supports [[symbolic computation]] with expressions. Here is an example showing the use of local rewriting rules to [[polynomial expansion|expand]] and [[factorization|factor]] simple arithmetic expressions:
Line 148 ⟶ 137:
hello;
</syntaxhighlight>
Instead of manually compiling source files to LLVM bitcode modules, one can also place the source code into a Pure script, enclosing it in %< ... %> (inline code, e.g. C, Fortran 77/90 and so on).
==See also==
|