DrScheme for My TCS Community
-
Upload
bebekdarat -
Category
Documents
-
view
220 -
download
0
Transcript of DrScheme for My TCS Community
-
8/8/2019 DrScheme for My TCS Community
1/20
DrScheme TutorialDrScheme Tutorial
PartPart II
dedicated todedicated to
TCS PreTCS Pre--ILP FriendsILP Friends
What to know? And .. What not toWhat to know? And .. What not to
know?know?
-
8/8/2019 DrScheme for My TCS Community
2/20
Before Getting into this Download DrScheme, version 372 (not any
other version) from the web. Visithttp://download.plt-
scheme.org/drscheme/all-versions.htmland choose Version 372. Done
If you know any language like C or Java oranything else, dump them into a dark room
as long as you learn Scheme. I mean,dont compare Scheme with any other lang.It will lead to problems in understanding.
-
8/8/2019 DrScheme for My TCS Community
3/20
Roll up your sleeves. NOW!!!
Install DrScheme 372, run it.
In the bottom of the window, choose
Textual (includesR5R
S) from thelanguage menu.
This Textual language is what wehave to use for learning in Pre-ILP.
Click on the Run button in the topright corner of screen.
Now, you are done with initial things.
-
8/8/2019 DrScheme for My TCS Community
4/20
What is DrScheme? DrScheme is a programming
language like C, C++ or Java.
But, it is very much different fromany other language.
It speaks the language of humanintuition. Youll see this soon.
Nobody needs to teach you schemesyntax for more than, say tenminutes.
-
8/8/2019 DrScheme for My TCS Community
5/20
Why Scheme? Scheme is not a serious language currently used in
industry.
It is just a language which is used to learn the basicsof programming.
The concept of Scheme is to learn the art ofProgramming and not to learn any particular language.
So, you are expected to learn about how to program or,how to think logically about solving a given problem.
So, learn programming but, not thelanguage.
If you are able to solve a given problem using Scheme,then, you can solve it using any other language once thesyntax is known to you.
-
8/8/2019 DrScheme for My TCS Community
6/20
What do we see there? Once you run DrScheme, you will see a
window with two text areas one aboveanother.
First, we will concentrate about the bottomone and will come to the top one soon.
The bottom one is called Interactionswindow. It is used to get results from the
programs and to give input to theprograms.
We will start our experiments in theinteractions window.
-
8/8/2019 DrScheme for My TCS Community
7/20
Into DrScheme In the interactions window, after the
> mark, type any number, say 5
and press Enter. You will get thesame number as the result in(default) blue colour.
-
8/8/2019 DrScheme for My TCS Community
8/20
Experimenting DrScheme Type hello (include the double
quotes also) and you will get hello
as output.
Now, if you want to add twonumbers, try (+ 3 5)
-
8/8/2019 DrScheme for My TCS Community
9/20
Experimenting DrScheme I know, by now, you would have tried
-, * and / operators. I said, Its thelanguage of intuition
Then, try experimenting + with morethan 2 operators, say (+ 3 5 6 4)
Yes, same as what you guessed. Isntit?
-
8/8/2019 DrScheme for My TCS Community
10/20
Variables To declare a variable (used to store something), use
the keyword define, as (define a 10). This means a=10. So, now execute (define a 10) and what do you
expect as output?
Amazed? It returns nothing as output because its jobis to say that a=10 and its job is not to return thevalue of a. So, it wont return 10. Got it?
This is called Data Abstraction, as we hide thevalue (data) and give a name to it.
-
8/8/2019 DrScheme for My TCS Community
11/20
Manipulating Variables
Now, look at the following and youwill understand for yourself.
No need of explanation. Right?
-
8/8/2019 DrScheme for My TCS Community
12/20
Playing with operations Now, try this (+ 3 (+ 5 6)). I hope
you will all say the result unanimously
as 14. Yes. You did the Math right.. But, how
come you understood this Schemesyntax even before I explained!
-
8/8/2019 DrScheme for My TCS Community
13/20
Into Text Data To handle texts, we have Strings,
which are collections of characters
between and .
And, as you say, we can do this also:
-
8/8/2019 DrScheme for My TCS Community
14/20
YOU UGLY CHAM
ELEON !!! Now, look at this..
Stop screaming! The variable a is anumber in first line and then itbecomes a string later, showing noopposition!You ugly chameleon!!!
-
8/8/2019 DrScheme for My TCS Community
15/20
Scheme and (Y)OUR
mind
If I say a=3 to you, you will assume in your mindthat the variable a must be an integer, or number. Ineed not say to you that it is a number. Your intuitiondoes this work.
Similarly, Scheme does the work of intuition byassuming what you are coming to say.
So, no need for type declaration of variables as insome other languages.
Yipee!! Free from int, char, float, double, pointeretc.
And, actually, the chameleon is you, who screamed atScheme at the end of the last slide and who isdancing with joy at the end of this slide. No offense!Just for fun! LOL
-
8/8/2019 DrScheme for My TCS Community
16/20
This or That? To handle, true or false type,there is a data
type called boolean.
#t denotes true and #fdenotes false.
Now, look at this
The my_answer is now a boolean variable.
-
8/8/2019 DrScheme for My TCS Community
17/20
Scheme Sabhas Speaker Seat
To display, or shout, or whisper, or singanything, we use a keyword display.
Note the pink colour of the outputs! Evendouble quotes are missing in the stringoutput.
-
8/8/2019 DrScheme for My TCS Community
18/20
A
Bigconfusion, indeed !!!
I can hear you saying Why to unnecessarily use(display 10) instead of just typing 10 and pressingEnter?
First of all, note the colour change, from blue to pink.
A good joke!!! Indeed, its not a joke. It gives a clear indication thatsomething seriously different is happening internallybetween these two. Yes!!!
If you can guess the difference, you are a prodigy. But, if you cant then, you are fit for the job of a
software professional because, you have TRIED toguess. Trying is what matters. Only brave peopletry.
Ok. The answer is in the next slide.
-
8/8/2019 DrScheme for My TCS Community
19/20
The Serious Difference Look at this first and I will explain later.
The difference is simple. The results ofdisplay function are not reusable whereasthe results of +,-,*,/ are reusable.
-
8/8/2019 DrScheme for My TCS Community
20/20
End of Part I More about reusability in the next part..
The next part will be uploaded as soon as itis ready.
Please drop your suggestions, queries atthe forum or to [email protected]
Thank you. And, all the best.
Vivek Ganesan,
SASTRA University,
Thanjavur.