Original Grammar for Algebra Programs Change #1: Move ...
Original Grammar for Algebra Programs
::= *
::= () =
::= ( + )
::= ( ? )
::= ()
::= |
::= a variable name: f, x, y, z, ...
::= a number: 1, 42, 17, ...
Change step-by-step to Scheme
Change #1: Move Parens and Add "define"
::=
::=
::=
::=
::=
::=
::=
::=
*
(define ( ) )
(+ )
(? )
( )
|
a variable name: f, x, y, z, ...
a number: 1, 42, 17, ...
Open parenthesis for function call moved to before the function name
Change #1: Move Parens and Add "define"
::= *
::= (define ( ) )
::= (+ )
::= (? )
::= ( )
::= |
::= a variable name: f, x, y, z, ...
::= a number: 1, 42, 17, ...
+ and ? moved to initial position
Change #1: Move Parens and Add "define"
::= *
::= (define ( ) )
::= (+ )
::= (? )
::= ( )
::= |
::= a variable name: f, x, y, z, ...
::= a number: 1, 42, 17, ...
Definition use the define keyword, and parenthesis moved
1-6
Change #1: Move Parens and Add "define"
::=
::=
::=
::=
::=
::=
::=
::=
f(x) = (x + 1)
f((2 + 3))
*
(define ( ) )
(+ )
(? )
( )
|
a variable name: f, x, y, z, ...
a number: 1, 42, 17, ...
::=
::=
::=
::=
::=
::=
::=
::=
...
(+ *)
(? +)
(? *)
+
(/ )
(modulo )
(expt )
...
(+) ¡ú 0
...
(+ *)
(? +)
(? *)
+
(/ )
(modulo )
(expt )
...
(+ 1 2 3 7) ¡ú 13
(define (f x) (+ x 1))
(f (+ 2 3))
Change #2: Generalize + and -, Add Primitives
::=
::=
::=
::=
::=
::=
::=
::=
Change #2: Generalize + and -, Add Primitives
Change #2: Generalize + and -, Add Primitives
::=
::=
::=
::=
::=
::=
::=
::=
...
(+ *)
(? +)
(? *)
+
(/ )
(modulo )
(expt )
...
(? 1) ¡ú ?1
7-11
Change #2: Generalize + and -, Add Primitives
::=
::=
::=
::=
::=
::=
::=
::=
...
(+ *)
(? +)
(? *)
+
(/ )
(modulo )
(expt )
...
Change #2: Generalize + and -, Add Primitives
::=
::=
::=
::=
::=
::=
::=
::=
...
(+ *)
(? +)
(? *)
+
(/ )
(modulo )
(expt )
...
(?) ¡ú 1
(/ 2) ¡ú 1/2
Change #2: Generalize + and -, Add Primitives
Change #3: Generalize Defined Functions
::=
::=
::=
::=
::=
::=
::=
::=
...
(+ *)
(? +)
(? *)
+
(/ )
(modulo )
(expt )
...
::=
::=
::=
(define ( *) )
...
( *)
(define (f a b) (+ a b))
(f 1 2)
¡ú
(define (f a b) (+ a b))
3
(expt 13 20) ¡ú 19004963774880799438801
12-16
Change #3: Generalize Defined Functions
::=
::=
::=
(define ( *) )
...
( *)
... (define (0 1...k) 0) ...
... (0 1...k) ...
¡ú
... (define (0 1...k) 0) ...
... 3 ...
Change #4: Add Booleans
::=
::=
::=
::=
::=
::=
::=
::=
...
(and *)
(or *)
(zero? )
...
#f
#t
(and #t #f) ¡ú #f
where 3 is 0 with i replaced by i
Change #4: Add Booleans
Change #4: Add Booleans
::=
::=
::=
::=
::=
::=
::=
::=
::=
::=
::=
::=
::=
::=
::=
::=
...
(and *)
(or *)
(zero? )
...
#f
#t
(zero? 1) ¡ú #f
...
(and *)
(or *)
(zero? )
...
#f
#t
(zero? 0) ¡ú #t
17-21
Change #5: Add Symbols
::= ...
::=
::= (eq? )
::= ...
::= ¡¯
Change #5: Add Symbols
::=
::=
::=
::=
::=
...
(eq? )
...
¡¯
(eq? ¡¯a ¡¯a) ¡ú #t
(eq? ¡¯a ¡¯b) ¡ú #f
Change #6: Add Conditionals
Change #6: Add Conditionals
::=
::=
::=
::=
...
(cond *)
[ ]
[else ]
(cond [#t 1]) ¡ú 1
::=
::=
::=
::=
...
(cond *)
[ ]
[else ]
(cond [#f 1] [#t 2]) ¡ú (cond [#t 2])
(cond [#t 2]) ¡ú 2
22-28
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- dell color multifunction printer e525w user s guide
- ip camera user manual provision isr
- a note on beta approximation for change point estimator
- cisco webex room kit administrator guide collaboration
- ts3300 series online manual
- 0 6 0 1 change 1 annual tradables
- jetstream l2 managed switch tp link
- 1 0 3 implementation of topical reports change control
- uk 1 584 468 3 9 1 613 789 3 9 29 321 1 8 0 0 gb
- user s guide xp 4100 xp 4105
Related searches
- improving grammar for adults
- grammar for 8th graders
- grammar for 8th grade worksheets
- basic english grammar for beginners
- english grammar for beginners pdf
- mortal kombat 1 move list
- original mg42 for sale
- math notes for algebra 1
- algebra properties worksheet 1 27
- app for algebra problems
- apps for algebra 1
- math apps for algebra 1