|
|
|
|
Please go to
which is updated version of this homepage.
Information below is out-of-date and remains here only for keeping old links.
SAMPLE Language & Technology:
http://sampletalk.8m.com/.Word Inversion
Compare this program to the next two programs. The under-lines denote the nesting structure on samples.
|
% Goal: |
The output will be
reverse of the word abcdef is fedcba.This program demonstrates how a word processing algorithm can be constructed from natural language phrases describing this algorithm.
Word inversion 2
(this program is similar to the previous one but has more compact code).
|
[abcdef]-->[X].. % Goal |
The output will be [
abcdef]-->[fedcba]. These examples show that you can easily introduce your own syntax like []-->[] for expressing your favorite designations. The output will be [abcdef]-->[fedcba].
Inversion of a list of words (separated by /)
Compare this program to the previous two programs for word inversion. The only essential difference is two symbols / in the recursive rule, but performance is quite different.
|
reverse of the list abc/def/gh is X.. %Goal |
Output:
reverse of the list abc/def/gh is gh/def/abc. Note the readability of such programs: it's hard to imagine a program, which is more readable than what is composed from natural language descriptions of an algorithm.
Transformation of infix notation of arithmetic expressions into (polish) prefix notation
% Possible goals:
|
% The program is as simple as this: |
As the result, you will get the polish notations instead of the symbol "_" in the goals.
Note that "=>" isn't a language construction. You can write "-->", or something more expressive like "is translated to", "is" - anything you want to express the meaning of this transformation. For SAMPLE, only matching of sub-word "=>" to other occurrences of sub-words "=>" is important.
Replacing sub-words in a word
The goal for this program has the form
(Word2/Word1)SourceExpression=ResultingExpression
This program replaces all occurrences of word1 in the source expression by word2 (upper-case letters stand for text variables). See also applications of this program below.
|
% Goal: |
Output:
((y+2)/x7)[sin(2x7)+cos(4x7)]=[sin(2(y+2))+cos(4(y+2))].Note the similarity of the program constructions to the processed data: they are built just from such data!
Palindrome test
This program tests a word whether it is a palindrome and finds its 1-st half (the goal is the 1-st line; the half will replace variable W).
|
% Goal |
Output:
[abcddcba]->abcd..List permutations
This is (probably) the shortest representation of an algorithm for generating list permutations, possible for universal programming languages. You can even exclude the words "permutation for", "is", and the program will do the same.
|
% Goal |
Generating words in the form W [W-1] W:
Generation of words of the type W [W-1] W (see the comment below), which is impossible for CF grammars.
|
%Goal |
Comment: The program generates words [a][a][a], [b][b][b], [aa][aa][aa], [ab][ba][ab], [abab][baba][abab] etc, where the 2-nd word is inverse of the 1-st and 3-rd words which are equal.
Bubble sort of a digit list
In this program, just finding the digits in the ascending digit list tests the order of digits.
|
% Goal (W is to be filled by the sorted list) |
Such programs will never need a detailed documentation: since text matching is the main programming concept, the reader will always find explanation of program elements in other similar elements.
Bubble sort of numbers
In this program, the order of numbers is tested by incorporated Prolog predicate <.
|
% Goal: |
SAMPLE Language & Technology:
http://www.webspawner.com/users/samplex/
Back to SAMPLE Language @ Technology |
Other examples: NL Parsing & Understanding |
Other examples: Logics; Recognition of Regularities |
Metaphoric Conclusion about SAMPLE Technology |
Send E-Mail to: gleibman@yahoo.com