Scheme - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Scheme

Description:

??????? ????? ??????? ??? ?? ??????? ???? ???? (??????? ... With DrScheme stepper*: *works for Beginning Student Language level only. 23. special forms, ???? ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 29
Provided by: csta3
Category:
Tags: run | scheme | stepper | up

less

Transcript and Presenter's Notes

Title: Scheme


1
???? ????? ????? ????? ???? Scheme
  • ????? 1

2
??????? ??????
  • ??? ????? (???? ?????? ????, ????? ???? ?????(
  • ??? ????? www.cs.tau.ac.il/scheme
  • ???????
  • ?????
  • ????? (????? ???? ?????)

3
http//www.cs.tau.ac.il/scheme
4
???????
  • ??????? ??????? ?????? ????.
  • ???? ???????? ??? ?????.
  • ??????? ????? ??????? ??? ?? ??????? ???? ????
    (??????? ??? ??????? ????).
  • ???? ????? 80 ????????? ??????.
  • ???? ?????? ???????? ??? ??? 005 ????? ?????,
    ????? ??????.
  • ????? ??, ?.?., ???? ?????, ?????? ????.
  • ????? ????? ???? ????? ????? ??????.
  • ????? ???? ?????.

5
Scheme
  • Lisp List Processing
  • ?????? (interpreter) ???? ??????? ?-Lisp
  • Scheme ??? ?? Lisp
  • ????? ?? ????, ????? ?????????? ??? ???????.

6
Dr. Scheme ?????
  • ????? ?????? (????? 209)
  • ????? ????, ??? ??? ?????, ??
  • http//www.drscheme.org
  • ????? ?????? ?????? ?????? ?????? ????? Linux
  • drscheme
  • ?????? ??????? (????)
  • Language-gtChoose Language-gt
  • Graphical (under
    PLT tab)
  • (???? ?????? ?? ????? ?? ????? ?-Run)

!
7
(No Transcript)
8
???? ???????
???? ???????????
9
????? ?????
10
????? ????? ???????
11
??????? ?-Scheme (?????)
  • ????? ???? lt,,586
  • ?-interpreter ???? ?????? ????? ?????? ?? ??????.
  • ?????????
  • ( 1 3 5 7)
  • ????? ??????? ??? ???????, ??????? ?????????.
  • ???????? ????? ????????? prefix notation.

12
????? ????? ???????????
13
????? ????? ???????
Click on Run
14
Nesting
  • ????? ?? ?????????? ?????????? ??????????
  • ???? ?? ??????????.
  • ( ( 100 1)
  • ( (- 10 7)
  • (/ 24 6)
  • )
  • (

15
???? ????? ?? DrScheme
16
??? ?????
  • ????? ?-interpreter ????? ???-??????? (????????
    ????????) ??? ????? ?? ???????? ?? ?????????.
  • ???? ??? ????? ????????.

17
??????? ?-,Scheme ????
  • ???? (define x 7)
  • ??????? ?????? ?????? ?? ???????????.
  • ???? ???? ??????, ???? ????? ??????? ??
  • ????????, special form, ????? ??? ???? ???
  • ?? ?????? ?? ?????????.
  • ????? ?????? ????? ????? ?? ?? ????, ???????
  • ???? ??????, environment.

18
??????? ?-,Scheme ????
  • ????????
  • (lambda (x) ( x x))
  • ????????? (,) ?? ?????? (square)
  • (lambda (parameters ltgt) ltbodygt)
  • ?????
  • ((lambda (x) ( x x)) 7)

19
???? ??????
  • ???? ?????? (syntactic sugar), ??? ????? ??????
    ????? ????? ????? ???? ?? ????.
  • (define (square x) ( x x))
  • (define (name ltparametersgt) ltbodygt)
  • (square 7)
  • (define (sum-of-squares x y)
  • ( (square x) (square y)))
  • (sum-of-squares 3 4)

20
???? ?????
  • ?????? ???-???????, ???????? ????????, ??????
    ???????? ?? ?????????.
  • Normal order evaluation
  • ???? ????? ???????? ??????? ??? ?????
  • ???????? (expand), ??? ????? ??????? (reduce)
  • Applicative order evaluation
  • ????? ?? ????????? ??? ????? ?? ????????.

21
Normal vs. Applicative order
(define (square x) ( x x)) (define
(sum-of-squares x y) ( (square x)
(square y))) (define (foo a) (sum-of-squares ( a
1) ( a 2))) (foo 5)
  • Normal order
  • (sum-of-squares ( 5 1) ( 5 2))
  • ( (square ( 5 1)) (square ( 5 2)))
  • ( ( ( 5 1) ( 5 1)) ( ( 5 2) ( 5 2)))
  • ( ( 6 6) ( 10 10))
  • ( 36 100)
  • 136
  • Applicative order
  • (sum-of-squares ( 5 1) ( 5 2))
  • 6 10
  • ( (square 6) (square 10))
  • ( ( 6 6) ( 10 10))
  • ( 36 100)
  • 136

22
What is the Scheme order?
(define (square x) ( x x)) (define
(sum-of-squares x y) ( (square x)
(square y))) (define (foo a) (sum-of-squares ( a
1) ( a 2))) (foo 5)
With DrScheme stepper
works for Beginning Student Language level only
23
special forms, ????
  • (if ltpredicategt ltconsequentgt ltalternativegt)
  • predicate ?????? ???? ??????? true ?? false.
  • ?? ???? ??? true,
  • ????? ?? consequent ?????? ?? ????? ???????.
  • ????, ????? ?? alternative ?????? ?? ?????
    ???????.

24
????? ??? ?????
  • (define (abs x)
  • (if (lt x 0)
  • (- x)
  • x))

25
??? ?????
  • (define (foo a b)
  • ((if (gt b 0) -) a b))
  • (foo 2 6)
  • (foo 5 -4)

26
????????? ??????
  • (and (lt x 95) (gt x 85))
  • ????? ??? ???? ?? ?-false ??????.
  • (or (gt x 95) (lt x 85))
  • ????? ??? ???? ?? ?-true ??????.
  • ??? special-forms, ??? ?? ????? ??????? ??
    ????????.

27
?????? ??????
  • Scheme ???? ?"?????? ??????", ???? ???????
    ???????? ?????????? ??????????? ???? ????? ??? (
    gt 232-1, gt 264-1)

28
?????? ????????? ????????
Write a Comment
User Comments (0)
About PowerShow.com