NUIM/CS351 Lecture 01 Notes

Module: CS351 (Programming Paradigms)
Lecturer: Barak Pearlmutter
Lecture No: 1

The Tower of Power

One goal of this course is to get knowledge of other programming languages and paradigms, and to move up the "Tower of Power."

Scheme

Implementation: DrScheme (part of the PLT Scheme software suite)

Scheme is:

Note: during class when lambda is written on the board everybody must shout "The Power"!

Syntax of Scheme

() Parenthesis have two separate uses
  1. Calling functions
  2. "Special" constructs
Note: Parenthesis are not used for grouping in Scheme, as they are in Java.

Calling functions

Scheme Java
(sin 1) sin(1), or (((sin((1)))))
(+ 2 3) 2 + 3
(* 6 9) 6*9 or (((((6)))*((9))))
(lambda (x) (+ x 1)) ? (cannot easily write anonymous function)
(define add-one (lambda (x) (+ x 1))) int addOne(int x){ return x+1); }
(if (< 2 2) 777 888) (2 < 2) ? 777 : 888

Comments

Points taken off for comments in code!

;;; (factorial n)
;;; n!
;;; 0! = 1
;;; 1! = 1
;;; 2! = 2