Войти в систему

Home
    - Создать дневник
    - Написать в дневник
       - Подробный режим

LJ.Rossia.org
    - Новости сайта
    - Общие настройки
    - Sitemap
    - Оплата
    - ljr-fif

Редактировать...
    - Настройки
    - Список друзей
    - Дневник
    - Картинки
    - Пароль
    - Вид дневника

Сообщества

Настроить S2

Помощь
    - Забыли пароль?
    - FAQ
    - Тех. поддержка



Пишет blggr ([info]blggr)
@ 2006-12-28 22:35:00


Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Музыка: structure and interpretation of computer programs
Entry tags:sicp

1.2 1.3 1.5
#| the output is from MIT's Scheme compiler |#

; 1.2

1 ]=> (/ (+ 5 4
(- 2
(- 3
(+ 6 (/ 4 5)))))
(* 3
(- 6 3)
(- 3 7)))

;Value: -37/90
1 ]=>



; 1.3
1 ]=> (define (sum-of-squares a b) (+ (* a a) (* b b)))

;Value: sum-of-squares

1 ]=> (define (sum-of-larger-nums a b c) (cond ( (and (<= a b) (<= a c)) (sum-of-squares b c)) ( (and (<= a b) (>= a c)) (sum-of-squares a b)) ( (and (<= a c) (>= a b)) (sum-of-squares a c)) (else (if (< b c) (sum-of-squares a c) (sum-of-squares a b)))))

;Value: sum-of-larger-nums
1 ]=>

; 1.5

#|
normal-order evaluation will postpone evaluating the value of (p) until the first condition of if-clause fails. Since x==0, (p) will never be evaluated, and the value of 0 will be returned by the invocation of test.

applicative-order evaluation will first evaluate argument values. Therefore it will trip on (p), which is undefined (???). In other words, it will never reach the stage of performing test on the operands
|#