计算机程序的构造和解释(SICP) Assignment 1 Introductory assignment
之前把SICP整体过了一遍,完成了70%左右的习题,不过后几章还有不少疑问,所以现在进行二刷,结合官网的assignment进行学习,这次回顾Assignment 1 Introductory assignment。
学习资料:
https://github.com/DeathKing/Learning-SICP
https://mitpress.mit.edu/sites/default/files/sicp/index.html
https://www.bilibili.com/video/BV1Xx41117tr?from=search&seid=14983483066585274454
作业地址:
https://mitpress.mit.edu/sites/default/files/sicp/psets/index.html
Exercise 1
没有错误。
Exercise 2
代码:
(define fact
(lambda (n)
(if (= n 0)
1
(* n (fact (- n 1))))))
(fact 243)
实验结果:
1 ]=> (fact 243)
;Value: 57651072073405564859932599378988824389544612769748785289578514753791226660795447787952561780489668440613028916503471522241703645767996810695135226278296742637606115134300787052991319431412379312540230792060250137088708811794424564833107085173464718985508999858791970609491066045711874321516918150905413944789377156315207186998055591451670633898714567745386826936678840548225648089961727875705444538167142818292862812160000000000000000000000000000000000000000000000000000000000
Exercise 3
代码:
(load "ps1-ans.scm")
(define (comb n k)
(/ (fact n) (fact k) (fact (- n k))))
(comb 243 90)
实验结果:
1 ]=> (comb 243 90)
;Value: 193404342391239489855973693417880600543891038618846567058277413638164
后续部分为ide使用,这里从略。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Doraemonzzz!
评论
ValineLivere