Pure (programming language): Difference between revisions

Content deleted Content added
Ag (talk | contribs)
Expand a bit on application areas and features which set Pure apart from its predecessor Q and other FPLs.
Ag (talk | contribs)
Add a symbolic computation example.
Line 79:
let x = dmatrix {2,1,-1,8; -3,-1,2,-11; -2,1,2,-3};
x; gauss_elimination x;
 
[[Symbolic computation]] example with local rule sets:
 
expand = reduce with
(a+b)*c = a*c+b*c;
a*(b+c) = a*b+a*c;
end;
factor = reduce with
a*c+b*c = (a+b)*c;
a*b+a*c = a*(b+c);
end;
/* Example: */
expand ((a+b)*2); // yields a*2+b*2
factor (a*2+b*2); // yields (a+b)*2
 
Calling [[C (programming language)|C]] from Pure is very easy. E.g., the following imports the <code>puts</code> function from the C library and uses it to print the string <code>"Hello, world!"</code> on the terminal: