Saturday, 24 November 2012

LISP INTERPRETER






LISP is a programming language with unique features. It is conceptually interactive. Input com- mands are given one by one and the associated result values are typed-out. LISP is an applicative language, meaning that it consists mainly of functional application commands. Besides function ap- plication, there are forms of assignment commands and conditional commands written in functional form. In general, iteration is replaced by recursion.


The data values on which a LISP function may operate includes real numbers. Thus, an expression
like “1.5 + 2” is a LISP statement which means: type-out the result of applying + to the argu-
ments 1.5 and 2. In LISP, function application statements are always written in prefix form, e.g.
+(1.5, 2). Moreover, rather than writing f (x, y) to indicate the result of the function f applied
to the arguments x and y, we write (f x y ) in LISP, so (+ 1.5 2) is the LISP form for “1.5 + 2”.
Finally, functions in LISP are usually specified by identifier names rather than special symbols.
Thus the correct way to compute 1.5 + 2 in LISP is to enter the expression (PLUS 1.5 2), which will,
indeed, cause “3.5” to be typed out. An expression such as (PLUS 1.5 2) is called a function call
expression. LISP functions can also operate on lists of objects; indeed the name “LISP” is derived
from the phrase “LISt Processing”.

LISP is commonly implemented with an interpreter program called the LISP interpreter. This
program reads LISP expressions which are entered as input and evaluates them and types out
the results. I will describe how a particular LISP interpreter is constructed in javascript on the next blog post.

Before discussing about Interpreter construction, take a look on the basic two parts of an Interpreter :

(a) Parsing 
(b) Execution

Parsing : The parsing component takes an input program in the form of a sequence of characters, verifies it according to the syntactic rules of the language, and translates the program into an internal representation. In a simple interpreter the internal representation is a tree structure that closely mirrors the nested structure of statements or expressions in the program. In a language translator called a compiler, the internal representation is a sequence of instructions that can be directly executed by the computer.

Execution :The internal representation is then processed according to the semantic rules of the language, thereby carrying out the computation.

The Lisp Parser is implemented with the function parse. Execution is implemented with the function eval.

A list such with a special keyword in the first position is called special form in Scheme. Here we need six special forms and three syntactic constructors.



9. procedure call 



[Expecting Your Valuable Comments]
Thank You

Friday, 16 November 2012

HUFFMAN CODING





Huffman coding is a technique which attempts to reduce the amount of bits required to represent a string of symbols. The algorithm accomplishes its goals by allowing symbols to vary in their length. Shorter codes are assigned to the most frequently used symbols in a string and longer codes to the symbols which appear less frequent.

Using binary tree with nodes containing the symbols and the probabilities of its occurrence, Huffman code can be generated.

Construct a tree as follows:
Step 1.Create leaf nodes for each symbols along with its probabilities of occurrence.
Step 2.Select the two leaf nodes with the lowest probabilities.
Step 3.Create a new node which is the parent of the two lowest probability nodes.
Step 4.Assign the new node the probability which is equal to the sum of its children's probabilities.
Step 5.Repeat from Step 2 until there is only one leaf node left.

Click here to get Huffman-Coding in python.

See this example to make your concept clear:

Character           Frequency
     'b'                         3
     'e'                         4
     'p'                         2
     ' '                          2
     'o'                         1
     '!'                          1
     'r'                          1

Now place these characters with their frequency as priority:


Now we get the first two elements and create link between them by creating a new binary tree node and add their possibilities. After that add the new node we created with sum of its priorities of it's children. 


Repeat the same steps:





At last we got the final tree:

Now to get the code corresponding to the symbols assign 0 to the left branch and 1 to the right branch.



Thus we get the corresponding codes for the symbols:

Character              Code
     'b'                        00
     'e'                        11
     'p'                       101
     ' '                        011
     'o'                       010
     '!'                       1000
     'r'                       1001


To decode the string of bits we need to traverse the tree for each bit, if the bit is 0 we take left step else if its 1 we take a right step until we hit a leaf.


[Expecting Your Valuable Comments]
Thank You

Friday, 9 November 2012

ESB-TRASLATOR





ESB is an open standards-based distributed synchronous or asynchronous messaging middleware that provides secure interoperability between enterprise applications via XML, Web services interfaces and standardized rules-based routing of documents.


Data transformation is the activity or the actual process that moves and changes the data from one format to another . Data transformation is the heartbeat of an ESB and usually involves producer and a consumer. The producer generates the data in one format and the consumer processes the data in another format. Producers and consumers can use a wide array of data formats, so its important to transform the data into a standard format.


System Interface Flow :
ESB-Translator Flow :


[Expecting Your Valuable Comments]
Thank You