Q (programming language)

Q (programming language)

Infobox programming language
name = Q
logo =
paradigm = multiparadigm: functional, object-oriented
year =
designer = Albert Gräf
developer =
latest release version = 7.5
latest release date = September 12, 2006
typing = dynamic, strong
implementations = Q
dialects =
influenced_by =
influenced =

Q stands for equational programming language. It is an interpreted, interactive functional programming language created by Albert Gräf at the University of Mainz in Germany. Q programs are just collections of equations which are used to evaluate expressions in a symbolic fashion. Q has many similarities with other modern functional programming languages like Haskell and ML, but is based on general term rewriting (a method of computation also used by the Mathematica computer algebra system) instead of the lambda calculus.

Despite its conceptual simplicity, Q is a full-featured functional programming language with a modern syntax, currying, dynamic typing using an object-oriented type system, exception handling, POSIX multithreading, a comprehensive standard library, and an interface to the C programming language. Q is an impure functional language (i.e., operations with side-effects are permitted) with a default eager evaluation strategy; "special forms" can be used to implement data structures and operations featuring lazy evaluation. Q has been ported to a variety of operating systems, including BeOS, FreeBSD, Linux, Mac OS X, Solaris and Microsoft Windows. The interpreter is free software distributed under the GNU General Public License.

Various add-on modules are provided for interfacing, e.g., to GNU Octave, OpenDX (IBM's scientific visualization software), Tcl/Tk and ODBC. A graph editor and library is also available. This turns the language into a practical tool for scientific and other advanced applications. Q also comes with an extensive system interface (though not as comprehensive as the facilities provided by other scripting languages such as Perl and Python). Moreover, computer music applications are supported via portable interfaces for MIDI and digital audio programming.

Examples

A "hello world" example:

hello = writes "Hello, world! ";

The following function generates the "stream" (a.k.a. infinite list) of all prime numbers:

primes = sieve (ints 2); ints N = bin N (ints (N+1)); sieve (bin X Xs) = bin X (sieve (filter (ndivby X) Xs)); ndivby M N = N mod M <> 0;

An algorithm to solve the "N queens" problem, using backtracking:

queens N = search N 1 1 [] ; search N I J P = write P || writes " " if I>N; = search N (I+1) 1 (P++ [(I,J)] ) || fail if safe (I,J) P; = search N I (J+1) P if JA tiny system programming example (fetch a file from a WWW server over a socket):

/* make sure SIGPIPE (broken connection signal) is ignored */ def _ = trap SIG_IGN SIGPIPE; /* fetch a file from an http server (port 80) */ http HOST NAME = close FD || bstr REPLY where FD:Int = socket AF_INET SOCK_STREAM 0, _ = connect FD (HOST,80), _ = send FD 0 (bytestr (sprintf "GET %s " NAME)), REPLY = recv_loop FD (bytestr ""); /* read data in 64K chunks */ recv_loop FD S = recv_loop FD (S++T) if #T>0 where T:ByteStr = recv FD MSG_WAITALL (64*1024); = S otherwise;

External links

* [http://q-lang.sourceforge.net/ Q-lang homepage]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Programming language — lists Alphabetical Categorical Chronological Generational A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that… …   Wikipedia

  • Programming language theory — (commonly known as PLT) is a branch of computer science that deals with the design, implementation, analysis, characterization, and classification of programming languages and programming language features. It is a multi disciplinary field, both… …   Wikipedia

  • Programming Language Design and Implementation — (PLDI) is one of the ACM SIGPLAN s most important conferences. The precursor of PLDI was the Symposium on Compiler Optimization, held July 27–28, 1970 at the University of Illinois at Urbana Champaign and chaired by Robert S. Northcote. That… …   Wikipedia

  • Programming Language for Business — or PL/B is a business oriented programming language originally called DATABUS and designed by Datapoint in the early 1970s as an alternative to COBOL because its 8 bit computers could not fit COBOL into their limited memory, and because COBOL did …   Wikipedia

  • programming language — ➔ language * * * programming language UK US noun [C] ► COMPUTER LANGUAGE(Cf. ↑computer language) …   Financial and business terms

  • programming language — Language Lan guage, n. [OE. langage, F. langage, fr. L. lingua the tongue, hence speech, language; akin to E. tongue. See {Tongue}, cf. {Lingual}.] [1913 Webster] 1. Any means of conveying or communicating ideas; specifically, human speech; the… …   The Collaborative International Dictionary of English

  • Programming Language One — Programming Language One, oft als PL/I (auch PL/1, PL1 oder PLI) abgekürzt ist eine Programmiersprache, die in den 1960er Jahren von IBM entwickelt wurde. Die Bezeichnung PL/1 ist vor allem in Deutschland gebräuchlich. Ursprünglich wurde PL/I… …   Deutsch Wikipedia

  • Programming Language 1 — noun A computer programming language which combines the best qualities of commercial and scientific oriented languages (abbrev PL/1) • • • Main Entry: ↑programme …   Useful english dictionary

  • Programming Language —   [engl.], Programmiersprache …   Universal-Lexikon

  • Programming language specification — A programming language specification is an artifact that defines a programming language so that users and implementors can agree on what programs in that language mean.A programming language specification can take several forms, including the… …   Wikipedia

  • programming language — noun (computer science) a language designed for programming computers • Syn: ↑programing language • Topics: ↑computer science, ↑computing • Hypernyms: ↑artificial language …   Useful english dictionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”