Introduction
To whet your appetite, here are some programming examples for your browsing pleasure. You might also wish to refer to our very, very brief introduction to Pure, to help you reading the examples, and the standard library scripts, in particular the prelude, for definitions of the predefined operations.
Examples
Some basic examples first.
- hello.pure: Start here to quickly get an idea how Pure programs look like.
- avltree.pure: An example illustrating how AVL trees can be implemented in Pure.
- recursive.pure: One of the benchmarks from the Language Shootout. Have some fun comparing this to other language versions available here.
- sortalgos.pure: Some classical sorting algorithms in Pure.
- sudoku.pure: Peter Bernschneider's Sudoku solver.
Matrix examples. These show off the new GSL matrix capabilities built into Pure 0.7 and later.
Calling foreign code. These examples illustrate how easy it is to interface to your own code written in C, Fortran and other languages in order to "outsource" expensive operations such as heavy number crunching.
The following examples illustrate some of Pure's metaprogramming and symbolic evaluation capabilities:
- quasiquote.pure: An implementation of a Lisp-like quasiquote operation which makes it easy to manipulate expressions as literals. (An alternative implementation can be found here, and some usage examples here.)
- reflection.pure: A Pure program can inspect (and modify) itself, very much like Lisp programs. (This is just a very basic example. Please check the manual for more.)
- rules.pure: An example showing how to implement local rewriting rules with the reduce builtin.
- symbolic.pure: Simplistic symbolic algebra examples (symbolic differentiation, disjunctive normal form).
Also make sure you have a look at some of Libor Spacek's examples:
- date.pure: A Mayan calendar counting off the days until the current cycle ends. A "must have" for hobby doomsday prophets!
- queens.pure: Some additional n-queens algorithms, including Libor's blazingly fast non-backtracking solution.
That are all the featured examples for now. More examples can be found in the sources.