Customer center

We are a boutique essay service, not a mass production custom writing factory. Let us create a perfect paper for you today!

Example research essay topic: Programming Language X X - 1,725 words

NOTE: Free essay sample provided on this page should be used for references or sample purposes only. The sample essay is available to anyone, so any direct quoting without mentioning the source will be considered plagiarism by schools, colleges and universities that use plagiarism detection software. To get a completely brand-new, plagiarism-free essay, please use our essay writing service.
One click instant price quote

Each programming language presents a particular world view in the features it allows, supports, and forbids. This series of articles describes the world view of the Scheme Programming Language. This view contains many elements desired in a modern programming language: multi-paradigm support, comparable, reusable abstractions, ability to create languages specialized for particular applications, clean separation of the generic and the implementation specific, and scalability from stand alone utilities to major software systems. Scheme started as an experiment in programming language design by challenging some fundamental design assumptions.

It is currently gaining favor as a first programming language in universities and is used in industry by such companies as DEC, Scheme is a small, exceptionally clean language which is, very importantly, fun to use. The language was designed to have very few, regular constructs which compose well to support a variety of programming styles including functional, object-oriented, and imperative. The language standard is only about 50 pages, including a formal, denotational definition of its semantics. Scheme is based on a formal model (the lambda calculus), so there are plenty of nice properties for the theoreticians and one can build knowledgeable code transformation tools reliably. Scheme has lexical scoping, uniform evaluation rules, and uniform treatment of data types. Scheme does not have the concept of a pointer, uninitialized variables, specialized looping constructs, So what does Scheme look like?

Well, it looks a lot like Lisp. Don't let this put you off. We can change how it looks (and will in a future article). But what is important are the concepts behind it and what you can say with it. So let me make a few comparisons between Scheme and, say C. You already know that ( low x high) ( (low x) && (x high) ) (+ ( 2 3) ( 4 5) ) () ) (define (sq x) ( x x) ) int sq (int x) { return (x x) } In Scheme, all data types are equal.

What one can do to one data type, one can do to all data types. This is different from most languages which have some data types that can do special things and other data types which are specially restricted. In most languages numbers have special rights because they can be used without having names (imagine having to name each number before using it! ). Functions are specially restricted because they In Scheme, unnamed functions are created with the key word (lambda (x) ( x x) ) - a function ( (if (foo? x) +) 2 3 4) - if (foo? x) is true, (define (curried-add x) (lambda (y) (+ x y) ) (define add 3 (curried-add 3) ); ; add 3 is a function - Variables can hold values of any type. - Names refer to values; names are not required. - An expression is one or more forms between parentheses. - To evaluate an expression, evaluate all the terms first and apply the value of the first form to the values of the other forms.

A nested expression counts as a form. - A comment starts at a semicolon (; ) and goes to the end of the - When a function is evaluated, it remembers the environment where it was evaluated. {So add 3 remembers that X has the value 3 when it evaluates ( (lambda (y) (+ x y) ) 7). } (define (sq x) ( x x) ) is just syntactic sugar for There are seven kinds of expressions: Variable reference: foo joe a-long-name-for-an-identifier + Procedure creation: (lambda (z) ( z z z) ) Conditional: (if ( x 3) sqrt modulo) Sequence: (begin (write x) (write y) (newline) ) Scheme has the usual assortment of data types: Characters: #a #A #b #B #space #newline Arrays (called vectors): # (1 2 "string" #x 5) Lists: (a little (list of) (lists) ) Functions (also called procedures) Symbols: this-is-a-symbol foo a 32 c$ 23 4 & 7 + 3 -is-a-symbol-too! - A vector's contents can be any data objects. - Symbols may include the characters + -. / = ! ? : $ % - Symbols are used for identifiers, so identifiers (variable - By convention predicates end in a question mark {e. g. string? } and side effecting procedures end in an exclamation mark {e. g. Numbers are especially interesting in that an integer is a rational is a real is a complex. There is no classification of numbers based on their storage class {e.

g. fixed, float, bonum, ... } but on whether or not they are exact. One of the joys of Scheme which initially confuses some people is the lack of inhibition. Scheme is very expressive, which means that one can say "the same thing" in many ways. In Scheme one has the freedom -- and the responsibility -- of saying exactly what is desired. We are all used to working around certain language features to get something done.

Scheme gets in the way very As a warming up exercise, let's build a pair. A pair consists of 2 elements obtained by the access routines FIRST and SECOND. The constructor is called PAIR. The relations to be maintained are (first (pair 1 2) ) - 1; (second (pair 1 2) ) - 2. For those of you who know LISP, this is not much to get worked up over. But how many ways can we implement the trio: pair, first, second?

There (define (PAIR a b) (vector a b) ); ; or just: (define PAIR vector) (define (FIRST a Pair) (vector-ref a Pair 0) ) (define (SECOND a Pair) (vector-ref a Pair 1) ) (define (PAIR a b) (lambda (bool) (if bool a b) ) ) (case msg; ; we " ll implement CASE in the next article ( (first) a); ; when the message is the symbol first, return a (define (FIRST a Pair) (a Pair 'first) ) (define (SECOND a Pair) (a Pair 'second) ) (define (PAIR a b) (lambda (proc) (proc a b) ) ) (define (FIRST a Pair) (a Pair (lambda (x y) x) ) ) (define (SECOND a Pair) (a Pair (lambda (x y) y) ) ) The moral of the above is not to assume anything about the implementation of interfaces -- even simple ones. Now that we are warmed up, let's take a look at ye ol' factorial ( n (fact (sub 1 n) ); ; (define (sub 1 n) (- n 1) ) When I first learned about recursive definitions like the one above, the hard thing to get used to was the how the hidden state kept on the stack. A transformation of the above code makes the; ; the identity function just returns its argument; ; keep invocation of fact the same, but do something different (define (fact n) (cart n identity) ); ; the transformed recursive factorial (lambda (result) (k ( n result) ) ) ) Cart is the continuation-passing version of fact. The basic idea here is that instead of returning a result each function takes an extra argument, the continuation, which is invoked with Let's look at what happens for (fact 3). (lambda (result) (identity ( 3 result) ) ) ); ; k' ( (lambda (result) (identity ( 3 result) ) ); fun k' ( (lambda (result) (identity ( 3 result) ) ) ( 2 result^) ) ) ( (lambda (result) (identity ( 3 result) ) ) ( 2 1) ) The point of this is not that we can take something simple and make it look bizarre. So why did I do it?

The point is that we can take control which is typically hidden on the stack at run time and study and manipulate it as source code. This lets us do some interesting things. For example, we can ignore the continuation passed in and use another one. If we are writing a game or an AI search routine or a mathematical routine which converges on a result, we can monitor our progress. If our progress is slow, we can save our continuation -- "where we are now" -- and try a different approach.

If the newer approach is even worse, we can go back to our saved continuation and try again from there. We can of course save our attempt at doing better to try again just in case it really was better... So continuation passing can let us build some pretty interesting control structures. Let's take another look at the simple function, fact. When we look at (fact 4), (fact 5), and so on, we see a common pattern.

Each call just stacks up a multiplication. Since we can see this, we can eliminate the stack and do the multiplication directly by introducing an accumulator. We take care of initializing the accumulator by noting that anything times one is the same as itself {i. e. the multiplicative identity: x 1 = x}. ; ; lexical scope means we can nest functions Now this looks a bit strange too. But there is an interesting detail here.

We did not have to build any new continuations! The continuation k^ which is given the final result is exactly the original continuation k. This means that the call of impact, which looks recursive, is really iterative. When it "calls itself" it does not add to the stack. The "recursive" call to Scheme requires no special looping constructs. Any function which calls itself in the "tail" position {i.

e. as the last thing to be done in the function} is just a loop. Most procedural languages do too much work. They "push a return address" even when they don't have to.

Scheme doen't. In Scheme, function calls can be thought of as goto's which can pass parameters -- one of which may This means that we can simplify cart to: Taking this a step further, we can redefine fact to call impact (if ( n 2) acc (impact (sub 1 n) ( n acc) ) ) Or taking advantage of Scheme's lexical scoping: (impact (sub 1 n^) ( n^ acc) ) Now we have transformed a recursive function into an iterative one. This can be done in a formal way, proving every code transformation. But a nice feature of Scheme is that such transformations can be seen and used directly. Correct programs can be written which are simple but perhaps ru...


Free research essays on topics related to: x y, e g, x x, programming language, n n

Research essay sample on Programming Language X X

Writing service prices per page

  • $18.85 - in 14 days
  • $19.95 - in 3 days
  • $23.95 - within 48 hours
  • $26.95 - within 24 hours
  • $29.95 - within 12 hours
  • $34.95 - within 6 hours
  • $39.95 - within 3 hours
  • Calculate total price

Our guarantee

  • 100% money back guarantee
  • plagiarism-free authentic works
  • completely confidential service
  • timely revisions until completely satisfied
  • 24/7 customer support
  • payments protected by PayPal

Secure payment

With EssayChief you get

  • Strict plagiarism detection regulations
  • 300+ words per page
  • Times New Roman font 12 pts, double-spaced
  • FREE abstract, outline, bibliography
  • Money back guarantee for missed deadline
  • Round-the-clock customer support
  • Complete anonymity of all our clients
  • Custom essays
  • Writing service

EssayChief can handle your

  • essays, term papers
  • book and movie reports
  • Power Point presentations
  • annotated bibliographies
  • theses, dissertations
  • exam preparations
  • editing and proofreading of your texts
  • academic ghostwriting of any kind

Free essay samples

Browse essays by topic:

Stay with EssayChief! We offer 10% discount to all our return customers. Once you place your order you will receive an email with the password. You can use this password for unlimited period and you can share it with your friends!

Academic ghostwriting

About us

© 2002-2024 EssayChief.com