摘要: (define (list-change total denoms) (define (cons-all num ls) (let ((num-val num)) (cond ((null? ls) nil) (else (cons (cons num (car ls)) (cons-all num 阅读全文
posted @ 2023-04-26 08:04 哎呦_不想学习哟~ 阅读(127) 评论(0) 推荐(0)
摘要: def mutate_reverse(link): """Mutates the Link so that its elements are reversed. >>> link = Link(1) >>> mutate_reverse(link) >>> link Link(1) >>> link 阅读全文
posted @ 2023-04-22 20:13 哎呦_不想学习哟~ 阅读(39) 评论(0) 推荐(0)
摘要: (define-macro (switch expr cases) (cons 'cond (map (lambda (case) (cons (eq? (eval expr) (car case)) (cdr case))) cases)) ) 这段代码是一个用于 Scheme 语言的宏定义,可以 阅读全文
posted @ 2023-04-21 21:43 哎呦_不想学习哟~ 阅读(125) 评论(0) 推荐(0)
摘要: (define-macro (def func args body) `(define ,(cons func args) ,body)) 分析: 定义一个万能的函数定义,那就要模拟函数定义的样子。ok,函数定义是什么样子的呢? eg: (define (filter-lst fn lst) (if 阅读全文
posted @ 2023-04-21 10:14 哎呦_不想学习哟~ 阅读(36) 评论(0) 推荐(0)
摘要: #lang sicp (define (unique s) (if (null? s) nil (cons (car s) (unique (filter (lambfa (x) (not (eq? x (car s)))) (cdr s))) ) ) ) 这是一个Scheme函数,名为unique 阅读全文
posted @ 2023-04-19 18:58 哎呦_不想学习哟~ 阅读(46) 评论(0) 推荐(0)
摘要: 1.list quote quasiquote The list procedure takes in an arbitrary amount of arguments. Because it is a procedure, all operands are evaluated when list 阅读全文
posted @ 2023-04-18 18:18 哎呦_不想学习哟~ 阅读(56) 评论(0) 推荐(0)
摘要: Write sub-all, which takes a list s, a list of old words, and a list of new words; the last two lists must be the same length. It returns a list with 阅读全文
posted @ 2023-04-17 18:57 哎呦_不想学习哟~ 阅读(61) 评论(0) 推荐(0)
摘要: item 1: 使用断言 item 2: Just end all of your lines with a comma 阅读全文
posted @ 2023-04-15 16:43 哎呦_不想学习哟~ 阅读(14) 评论(0) 推荐(0)
摘要: def reduce_armor(self, amount): """Reduce armor by AMOUNT, and remove the FireAnt from its place if it has no armor remaining. Make sure to damage eac 阅读全文
posted @ 2023-04-14 15:38 哎呦_不想学习哟~ 阅读(101) 评论(0) 推荐(0)
摘要: 题目: def is_bst(t): """Returns True if the Tree t has the structure of a valid BST. >>> t1 = Tree(6, [Tree(2, [Tree(1), Tree(4)]), Tree(7, [Tree(7), Tr 阅读全文
posted @ 2023-04-13 08:29 哎呦_不想学习哟~ 阅读(102) 评论(0) 推荐(0)