Qi (programming Language) - Core Language

Core Language

The Qi core language is a simplification of the Lisp language. Functions are written in prefix form. Symbols, variables, booleans, numbers, strings and characters are all self-evaluating if typed at the top level. Here are some examples.

Here is the traditional Hello world program in Qi:

(output "Hello, world~%")

Lists are constructed with with spaces separating the elements of the list.

A factorial function using pattern matching:

(define factorial 0 -> 1 N -> (* N (factorial (- N 1))))

A lambda function in Qi that multiplies its input by 2.

(/. X (* X 2))

The membership function using pattern-matching over lists. (Qi largely follows the Edinburgh syntax convention for matching (i.e. variables are headed in uppercase), except that spaces are used instead of commas to separate items.)

(define member _ -> false X -> true X -> (member X Y))

A function using guards that finds the first number greater than N in a list.

(define find_greater N -> (error "no number greater than ~A.~%" N) N -> M where (> M N) N -> (find_greater N Ns))

Read more about this topic:  Qi (programming Language)

Famous quotes containing the words core and/or language:

    True, there are architects so called in this country, and I have heard of one at least possessed with the idea of making architectural ornaments have a core of truth, a necessity, and hence a beauty, as if it were a revelation to him. All very well perhaps from his point of view, but only a little better than the common dilettantism.
    Henry David Thoreau (1817–1862)

    Language makes it possible for a child to incorporate his parents’ verbal prohibitions, to make them part of himself....We don’t speak of a conscience yet in the child who is just acquiring language, but we can see very clearly how language plays an indispensable role in the formation of conscience. In fact, the moral achievement of man, the whole complex of factors that go into the organization of conscience is very largely based upon language.
    Selma H. Fraiberg (20th century)