A Scheme Workshop Ben Leong NUS School of
A Scheme Workshop Ben Leong NUS School of Computing 31 July 2007
Welcome to So. C l Help you make an informed decision on whether to choose between CS 1101 and CS 1101 S NOT to teach you Scheme l About which class is more suitable for YOU NOT about which is better….
Overview l l What’s Scheme? Why Scheme? Module Synopsis (i. e. what to expect) What your seniors say
Brief History of CS 1101 S l The language Scheme was designed 25 years ago at MIT to teach programming methodology l The success of the MIT programming methodology module led to its adoption in many universities worldwide l Scheme was first introduced at NUS 10 years ago l I took this class at MIT in 1994.
Objectives l Teach Scheme as a programming language NOT! l Teach programming concepts l Inspire CONFIDENCE in students that ANYTHING can be solved if they try hard enough l Teach students TO THINK Computational Thinking
Introduction to Scheme l Scheme is expression oriented. Type an expression and its result will be printed out. l Works with a variety of types of numbers: integers (both positive and negative), fractions (rational numbers), and real numbers
Introduction to Scheme l Expressions use prefix notation. l Use (+ 2 3) instead of (2 + 3) l Use (* (+ 2 3) (- 3 1)) instead of (2+3)*(3 -1) l There is a wealth of predefined functions computes the square root of its argument. l + is also a predefined function l sqrt
Why Scheme? l Teaching a language is futile (Here today, gone tomorrow) l Scheme is simple as a language l So we can focus on the CONCEPTS instead of clunky language rules l Let’s see for ourselves…. .
Recursion l Express (divide) a problem into smaller similar problems l Solve the problem for a simple (base) case We are done (!) l Similar to Mathematical Induction
The Towers of Hanoi We have 3 pegs and a set of discs, all of different diameters. Objective: move the pile of discs to last peg, by: l l moving 1 disc at a time from 1 peg to another; never placing a disk on top of another disc with smaller diameter. Suppose you have not 3, but n discs …
The Towers of Hanoi l We must start somewhere…. l Suppose we have one disc …. l What if there are no discs? l. Nothing l Base to do! case
The Towers of Hanoi We notice the following pattern: if we want to move n disks from peg a to peg c using peg b as intermediary storage, then we: l assume we know how to move n− 1 disks to peg b, using peg c as intermediary storage; l we move disk n from a to c ; l we move n− 1 disks from b to c, using a as intermediary storage. RECURSION
The Towers of Hanoi (define (move-tower size from to extra) (cond ((= size 0) #t) (else (move-tower (- size 1) from extra to) (print-move from to) (move-tower (- size 1) extra to from)))) (define (print-move from to) (newline) (display "move top disk from ") (display from) (display " to ") (display to))
CS 1101 S: Programming Methodology (Scheme) l Lectures: l Wed 10 am-12 pm, Fri 11 am-12 pm, LT 15 l Recorded for webcast l Recitations: 1 hr/wk l Two TBA l or three groups: Prob Thurs, Venue Discussion Groups: 2 hr/wk l Three or four groups: TBA l Bid for group in CORS
Teaching Staff l l Lecturer: Dr. Ben Leong, benleong@comp. nus. edu. sg Office: S 14 #06 -14 Phone: 6516 -4240 Hours: TBA, or by appointment Undergraduate Discussion Group Leaders
Syllabus (in Brief) l l l l Numeric computations in Scheme Building recipes with functions Recursion Data structures: lists, trees Memoization & Dynamic Programming Generic operations Object oriented abstractions Java Covers core concepts of computer programming
Textbook : SICP l l FREE!! Available online at http: //mitpress. mit. edu/sicp/fulltext/book. html
Supplementary Text l l ALSO FREE!! Available online at http: //gustavus. edu/+max/conc rete-abstractionspdfs/index. html
Scheme Interpreter We will be using Dr. Scheme l It’s FREE!!! l Download from: http: //www. drscheme. org/ l
Assessment Overview Tutorial participation: l Problem sets: l Midterm exam: l 10% 30% 15% 3 Oct 2007 (Wed) 10 am-12 pm l Practical exam: 15% 7 Nov 2007 (Wed) 10 am-12 pm l Final exam: 26 Nov 2007 (Mon) Morning 30%
Tutorial Participation (10%) Questions will usually be given out prior to the recitations/discussion groups, sometimes not l Assessed mainly by tutors, with some inputs from lecturer from interactions during recitations & lectures l You need to be active, participate by offering solutions, making comments and asking questions. l
Midterm and Final Exams (15% + 30%) Standard fare – 2 hours each l Will test concepts, NOT memory l Open-sheet l l 1 x A 4 sheet of notes allowed for midterm l 2 x A 4 sheet of notes allowed for finals Sample midterms available on IVLE l Sample finals available from Library l
Problem Sets (30%) Seven problem sets l Due approximately once every two weeks l Graded by the Undergraduate Tutors l Crucial for learning the material in this class l This is effectively the lab component of the class l
Practical Exam (15%) “Test of the Pudding” l At the completion of Scheme syllabus l 2 hours to solve three programming problems of increasing difficulty l Sample exams available on IVLE
Other Highlights Will build a Lego Mindstorm robot in the middle of the Semester l Regular Programming Contests to keep students challenged l
CS 1101 S vs. CS 1101 Progression: CS 1101 S CS 1102 S CS 1101 CS 1102 l Two-semester sequence l l Discouraged from crossing over l CS 1101 S CS 1102, CS 1101 CS 1102 S l Similarities l. S and non-S versions both teach basic programming principles
CS 1101 S/02 S vs. CS 1101/02 l Differences l CS 1101 S/02 S cover more advanced topics l More challenging l CS 1102 S covers Java + more l Good introduction to many computer science topics
Which to take? Take CS 1101 S/02 S if you want to be challenged. l If you have programmed before l l No real advantage l In fact, can be a disadvantage! l If you have never programmed before l Great! You are not at a disadvantage. l Keep an open mind. l Some evidence show that female students cope better with Scheme than Java.
Java vs Scheme: What’s the Tradeoff? l Java: l l sophisticated, mature can be used for commercial applications but has many underlying concepts that a beginner may find hard to understand Scheme: l l simple, elegant easy to learn (hard to master) designed to illustrate the concepts will eventually learn Java anyway…. Mainly a question of personal choice (taste? )
What your seniors say…. I think Scheme really does bring about concepts easily. Java's messy, so messy for an amateur programmer. (on Problem Sets) They are all very difficult, but some are killers. [What doesn’t kill you makes you strong] I learnt a tiny bit of java before I attended this class and I was totally lost. Teaching introduction to programming in Scheme is a quite smart idea. I feel much better when I came back to Java at the end of this class.
What your seniors say…. I was warned by my seniors not to take scheme because they said it was very tough. . now when I’ve done this module , I agree that it is tough. . but it is worth the effort. . scheme makes u smarter !!! : ) Do you agree that Scheme is easier than Java? 32% NO; 68% YES! Luv the class, luv the company of students, luv the interaction with teachers, bla bla. . . Scheme's cool I think we need more classmates
More comments here …. http: //www. comp. nus. edu. sg/~bleong/ teaching/cs 1101 s 06 -midterm. htm l http: //www. comp. nus. edu. sg/~bleong/ teaching/cs 1101 s 06 -final. htm l l Just Google “cs 1101 s survey”!!!
Words of Advice l Don’t worry about the curve l Scheme is easier (or so I would claim), but doesn’t mean that CS 1101 S is an easier class l Take CS 1101 S still have to learn Java…. so it is definitely more work l Have to be prepared to work very hard in CS 1101 S
QUESTIONS
THANK YOU
- Slides: 35