DRSCHEME TUTORIAL PDF

hi! i am a student and i learning Dr Scheme, i think that is a good programing. Can you help me have many exercise and solution of Dr. Most likely, you’ll want to explore the Racket language using DrRacket, especially at the beginning. If you prefer, you can also work with the command- line. Beyond the ordinary programming environment tools, DrScheme provides an algebraic stepper tutorials, and homework assignments. Also, several upper .

Author: Baramar Yozshugal
Country: Nigeria
Language: English (Spanish)
Genre: Relationship
Published (Last): 27 March 2010
Pages: 190
PDF File Size: 11.77 Mb
ePub File Size: 17.71 Mb
ISBN: 580-7-81123-873-6
Downloads: 61827
Price: Free* [*Free Regsitration Required]
Uploader: Dalkis

This tutorial provides a brief introduction to the PLT Scheme programming language by using one of its picture-drawing libraries. Along the same lines, we assume that you will run the examples using DrScheme. Using DrScheme is the fastest way to get a sense of what the language and system feels like, even if you eventually use Scheme with Emacs, vi, or some other editor.

To draw pictures, we must first load some picture functions, which are part of a library for creating slide presentations. Copy the following into the definitions areawhich is the top text area that you see in DrScheme:. Then click the Run button. An expression can be just a value, such as the number 5 or the string “art gallery”:.

An expression can also be a function call. To call a function, put an open parenthesis before the function name, then expressions for the function arguments, and then a close parenthesis, like this:.

A result from the circle function is a picture value, which prints as an expression result in much the same way that numbers or strings print. Try giving circle the wrong number of arguments, just to see what happens:.

Note that DrScheme highlights in pink the expression that triggered the error but pink highlighting is not shown in this documentation. When you start composing function calls in Scheme, it looks like this:.

Learning to Program with DrScheme LG #

The function name starts with h because it combines pictures horizontally, and the next letter is c because the pictures are centered vertically. If you wonder what other functions exist — perhaps a way to stack pictures vertically and left-aligned? A browser window will open, and it will give you a link to the documentation for hc-append. Move back to the definitions area the top area and add two definitions, so that the complete content of the definitions area looks like this:.

Then click Run again. Now, you can just type c or r:. As you drscehme see, the hc-append function accepts an optional number argument before the picture arguments, and it accepts any number of picture arguments.

When a number is provided, it specifies the srscheme of space to add between pictures. We could have evaluated the define forms for c and r in the interactions area instead of the definitions area. A tutoril definition uses definejust like our shape definitions, but with an open parenthesis before the function name, and names for the function arguments before the matching close parenthesis:.

  ASTM B545 PDF

In the same way that definitions can be evaluated in the interactions area, expressions can be included in the definitions area. When a program is run, expression results from the definition area are shown in the interaction area.

The define form can be used in some places to create local bindings. For example, it can be used inside a function body:. An advantage of let is that it can be used in any expression position.

Also, it binds many identifiers at once, instead of requiring a separate define for each identifier:. A let form binds many identifiers at the same time, so the bindings cannot refer to each drschme. Instead of calling circle as a function, try evaluating rrscheme circle as an expression:. That is, the identifier circle is bound to a function a.

Since functions are values, you can define functions that expect other functions as arguments:.

Dr Scheme Tutorial

Having to write down the function via define would be a hassle, because you have to make up a name and find a place to put the function definition. The alternative is to use lambdawhich creates an anonymous function:. The parenthesized names after a lambda are the arguments to the function, and the expression after the argument names is the function drrscheme. A define form for a function is really a shorthand for a simple define using lambda as the value.

For example, the series definition could be written as. Most Schemers prefer to use the shorthand function form with define instead of expanding to lambda.

This rule applies to identifiers in a lambda body as well as anywhere else. Note how composing functions via rgb-maker creates a different alignment of objects within the picture compared to using rgb-series. The list function takes any number of arguments and returns a list containing the given values:. As you can see, a list prints as a pair of parentheses wrapped around the printed form of the list elements.

This connection between expressions and printed results is no coincidence, but we save that bit of culture for discussion elsewhere. In the documentation and in DrScheme, result parentheses are printed in blue, unlike expression parentheses. Another function that works with lists is apply. Like mapit takes a function and a list, but a function given to apply should take all of the arguments at once, instead of each one individually.

CSE Scheme Tutorial

The apply function is especially useful with functions that take any number of arguments, such as vc-append:. Note that vc-append rainbow square 5 would not work, because vc-append does not want a list as an argument; drschme wants a picture as an argument, and it is willing to accept any number of them.

The apply function bridges the gap between a function that wants many arguments and a list of those arguments as a single value. Furthermore, the module initially imports everything from the turorial designated by slideshowwhich exports picture-making functions as well as more commonly used functions such as list and map.

To import additional libraries, use the require form. Some modules are packaged in the PLT Scheme distribution or otherwise installed into a hierarchy of collections. Some modules are distributed through the PLaneT server, and they can be downloaded automatically on demand. For example, the first time that you evaluate the drschdme fragment:.

  LOCALE VIDEOSORVEGLIATO PDF

DrScheme automatically downloads version 1. Some modules live relative to other modules, without necessarily belonging to any particular collection or package. For example, in DrScheme, if you save your definitions so far in a file “quick. Schemers typically tutoeial new programs and libraries as modules that import each other through relative paths, and that use existing libraries from collections and planet. When drsheme program or library developed this way seems useful to others, it can be uploaded as a PLaneT package or distributed in the more old-fashioned way as an installable collection archive in either case without modifying the internal relative references among modules.

Instead of a circle, the result is a picture of the code that, if it were used as an expression, would produce a circle. In other words, code is not a function, but instead a new syntactic form for creating pictures; the bit between the opening parenthesis with code is not an expression, but instead tjtorial by the code syntactic form.

This helps explain what we meant in the previous section drscgeme we said that scheme provides require and the function-calling syntax.

Libraries are not restricted to exporting values, such as functions; they can also define new syntactic forms.

Learning to Program with DrScheme

One way to introduce a new syntactic form is through define-syntax with syntax-rules:. This kind of definition is a macro. Of course, the sword of syntactic extension cuts both ways: In fact, you might want to take a look at the source of this document. An object system is another example of a sophisticated language extension that is worth learning and using for Scheme users.

Objects are sometimes better than functions, even when you have lambdaand objects work especially well for graphical user interfaces.

The new form creates an instance of a class, where initialization arguments like label and width are provided by name. We can use make-pict-drawer in a canvas-painting callback to draw a picture into a canvas:.

This introduction to PLT Scheme purposely avoids many of the traditional ways of introducing and distinguishing Lisp or Scheme: Instead, PLT Scheme programmers typically program with functions, records, objects, exceptions, regular expressions, modules, and threads. If you are new to dscheme or if you have the patience to work through a textbook, we recommend reading How to Design Programs. If you have already read it, or if you want to see where the book will take you, then see Continue: For experienced programmers, to continue touring PLT Scheme from a systems-oriented yutorial instead of pictures, your next stop is More: Where to Go From Here.