计算机程序的构造与解释习题1.17

计算机程序的构造与解释(SICP) 计划用半年的时间把《计算机程序的构造与解释》这本书读完,并完成一半以上的习题。 所用的软件: 系统:windows xp 解释器:DrRacket, version 5.1 语言:SICP(PLaneT 1.13) ,如何获得该语言,请看这里。 习题答案目录: 第1章 构造过程抽象 1.1节 程序设计基本元素1.2节 过程与它们所产生的计算 第2章 构造数据抽象 阅读详情

迭代,不变量,一般说,定义一个不变量,要求它在状态之间保持不变,这一技术是思考迭
代算提设计问题时的一种非常强有力的方棒。

(define (fast-expt x n) 

  (iter 1 x n))

(define (fast-expt x n) 

  (iter 1 x n))

(define (fast-expt x n) 

  (iter 1 x n))

(define (fast-multi x n)   (iter 0 x n))

(define (iter c a b)

(cond ((= b 0)  c)

                   ((odd? n)  (iter (+c a) a (- b 1))

                   (else  (iter   c double(a) have(b) ) )

)

简单原理6*7=6+6*6=6+12*3=6+12+12*2=6+12+24*1



Scheme:被低估的计算思维训练场与抽象能力锻造器 在编程语言演进中,函数式编程范式始终是理解计算本质的核心路径。Scheme 作为 Lisp 家族中最精简、最贴近 lambda 演算的形式化系统,以极小语法基底(仅需 lambda、define、if 等少数原语)支撑起对过程抽象、状态建模与接口契约的深度推演。其‘可推导性’和‘可重定义性’特性,迫使学习者直面计算的公理化基础——从 Church 数字构造到惰性求值实现,每一步都在训练将问题映射为可组合、可验证变换管道的能力。这种思维迁移至工程实践,显著提升对 DSL 设计、规则引擎、状态机与算法管道等真实 阅读详情

相关推荐

PySpark机器学习生产化陷阱:跨节点依赖问题的7种解决方案

隐式依赖陷阱使用ldd解决方案:在基础镜像中预装和路径冲突终极解法依赖树瘦身技巧用conda-tree可减少40%环境体积PySpark机器学习生产化的核心矛盾在于分布式环境的确定性与灵活性不可兼得。轻量级方案(1-3)牺牲一致性换取灵活性重量级方案(4-6)牺牲灵活性换取确定性混合方案(7)针对特殊场景补充正如某AI平台架构师所言:“环境一致性不是技术问题,而是工程纪律问题选择适合团队当前阶段的方案,建立严格的依赖管理流程,才能让PySpark真正扛起生产环境的大旗。

datacanvas2426的博客 910

不变量(Rep invariant)和抽象函数(Abstraction function)

不变量(Rep invariant)和抽象函数(Abstraction function)心得

qq_46851582的博客 680

YF-S401水流量传感器在STM32上的精准计量实现

本文详细介绍了YF-S401水流量传感器与STM32微控制器的集成应用,实现精准水流计量。通过外部中断和外部时钟两种脉冲计数方案,结合硬件配置、软件滤波和校准技巧,确保高精度流量测量。适用于智能家居和工业自动化中的水控系统,提升系统稳定性和测量准确性。

rainy的博客 896

计算机程序设计艺术 卷1:基本算法 1.2.2习题

数、幂与对数

jinyongbomatt2008的专栏 341

Dify 1.0+内网部署全攻略:模型插件离线安装与信创环境适配

本文详细介绍了Dify 1.0+版本在内网环境中的部署全攻略,重点解析了模型工具插件的离线安装方法与信创环境适配技巧。通过实战经验分享,帮助企业在严格的内网隔离条件下高效部署AI平台,解决插件依赖和安装难题,提升大语言模型的应用效率。

weixin_29224529的博客 274

英飞凌AURIX™ TC3xx系列MCU的ISO 26262安全机制实战:从安全手册到代码集成的避坑指南

本文深入探讨英飞凌AURIX™ TC3xx系列MCU的ISO 26262安全机制实战应用,重点解析锁步核配置、ECC策略优化及SafeTlib库集成中的关键问题。通过代码示例和配置建议,帮助开发者实现ASIL D级别安全性,规避常见陷阱,提升汽车电子系统的功能安全合规性。

weixin_42558093的博客 404

计算机程序的构造与解释作业:练习1.16到1.19

1.16 这个题目就是直译一下题目里面的公式。看开始我看了一下前面的题目,就高高兴兴的写出来了。如下: (define (even? n) (= (remainder n 2) 0)) (define (fast-expt b n) (cond((= n 0) 1) ((even? n) (fast-expt (* b b) (/ n 2))) (else (* b (

ssjssh的专栏 1156

Kettle下载与安装教程【保姆版】

Kettle简介 Kettle最早是一个开源的ETL工具,全称为KDE Extraction, Transportation, Transformation and Loading Environment。后来Kettle重命名为Pentaho Data Integration 。 它由Java开发,支持跨平台运行,其特性包括:支持100%无编码、拖拽方式开发ETL数据管道;可对接包括传统数据库、文件、大数据平台、接口、流数据等数据源;支持ETL数据管道加入机器学习算法。 主要功能 Pentaho D

weixin_43407520的博客 12万+

计算机程序的构造和解释 练习题2.17

#lang racket (define (last-pair items) (if (null? (cdr items)) (car items) (last-pair (cdr items)))) (last-pair (list 1 2 3 4 5 6)) 运行结果 6

船长灬普朗克的博客 205

基于Solidworks的三维光路结构示意图绘制实例演示-技术细节

基于Solidworks的三维光路结构示意图绘制实例演示-技术细节

简单光学 1万+

RT-DETR算法优化改进:轻量级上采样CARAFE算子 | 注意力机制大作战

上采样操作CARAFE,具有感受野大、内容感知、轻量级、计算速度快等优点,引入RT-DETR二次创新;1)代替Upsample进行使用;

①答疑群聊服务;②YOLO大模型知识问答系统;③计算机视觉论文生成智能体; 1265

计算机程序的构造和解释 练习题3.17

添加一个临时变量emp,判断临时变量里面有没有目前判断的序对,没有的话就把这个序对添加进emp,有的话就直接算0个。 当然最后可以查看emp的长度来判断有多少个序对。 #lang R5RS ;;判断集合中是否有该元素,注意一定要用eq? (define (element-of-set? x set) (cond ((null? set) #false) ((eq? x (car set)) #true) (else (element-of-set? x (cdr set)

船长灬普朗克的博客 170

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

计算机程序的构造和解释 练习题3.20

添加一个临时变量emp,判断临时变量里面有没有目前判断的序对,没有的话就把这个序对添加进emp,有的话就直接算0个。 当然最后可以查看emp的长度来判断有多少个序对。 #lang R5RS ;;判断集合中是否有该元素,注意一定要用eq? (define (element-of-set? x set) (cond ((null? set) #false) ((eq? x (car set)) #true) (else (element-of-set? x (cdr set)

船长灬普朗克的博客 206

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

计算机程序的构造和解释 练习题1.27

我们把1.22和1.24两个找素数的过程融合,变成找carmichael数的方法,也就是一个数通过所有的费马检查,但是不通过最小因数检查。以下是变更后的过程。 #lang racket (define (square x) (* x x)) (define (runtime) ( current-inexact-milliseconds )) (define(smallest-divisor ...

船长灬普朗克的博客 192

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

计算机程序的构造和解释 练习题1.36

为了方便打印结果,因为每次guess会执行close-enough?过程,我们改造这个过程方便看执行步骤 #lang racket (define (average x y) (/ (+ x y) 2)) (define (fixed-point f first-guess) (define (try guess step) (define (close-enough? v1...

船长灬普朗克的博客 154

计算机程序的构造和解释 练习题1.37

从题目可以得到以下变换式: xk=>NkDkxk−1=>Nk−1Dk−1+xk.......x2=>N2D2+x3x1=>N1D1+x2 x_k=> \frac{N_k}{D_{k}}\\ x_{k-1}=> \frac{N_{k-1}}{D_{k-1}+x_k}\\ .......\\ x_{2}=> \frac{N_2}{D_2+x_{3}}\\ x_...

船长灬普朗克的博客 141

计算机程序的构造和解释 练习题1.46

将fixed-point直接改写为题目要求的过程,然后按照1.17的sqrt改造过程,结合fixed-point改造一个带平均阻尼的sqrt-damp过程。 #lang racket (define (iterative-improve improve good-enough?) (define (try guess) (let ((next (improve guess))) ...

船长灬普朗克的博客 199

计算机程序的构造和解释 练习题3.18

这道题和3.17类似,采用一个临时变量把已经存在的元素放进去,然后查看cdr在不在集合中,如果在集合中,就是个环形结构,如果遍历完整个序列,所有的元素都不重复,则序列不是环。 #lang R5RS (define (last-pair x) (if (null? (cdr x)) x (last-pair (cdr x)))) (define (make-cycle x) (set-cdr! (last-pair x) x) x) (define (element-

船长灬普朗克的博客 189

计算机程序的构造和解释 练习题2.95

先利用2.94练习的程序,定义p1 p2 p3,然后计算q1 q2,最后求出最大公约多项式。 (define p1 (make-polynomial 'x (make-sparse-terms '((2 1) (1 -2) (0 1))))) (define p2 (make-polynomial 'x (make-sparse-terms '((2 11) (0 7))))) (define p3 (make-polynomial 'x (make-sparse-terms '((1 13) (0 5))

船长灬普朗克的博客 191

SICP 解题集¶

SICP 解题集

qha0731的专栏 1204

SICP 习题解 第二章

计算机程序的构造和解释习题解答 Structure and Interpretation os Computer Programs Exercises Answer 第二章 构造数据抽象 练习2.17 (define last-pair-1 (lambda (input) (if (= (length input) 1) input ...

weixin_30299539的博客 324

数据结构刘畅c语言版课后答案,数据结构习题集答案--清华大学版

《数据结构习题集答案--清华大学版》由会员分享,可在线阅读,更多相关《数据结构习题集答案--清华大学版(114页珍藏版)》请在人人文库网上搜索。1、第1章 绪论1.1 简述下列术语:数据,数据元素、数据对象、数据结构、存储结构、数据类型和抽象数据类型。解:数据是对客观事物的符号表示。在计算机科学中是指所有能输入到计算机中并被计算机程序处理的符号的总称。数据元素是数据的基本单位,在计算机程序中通常作...

weixin_39961855的博客 4011

(转)习题1.19

(转)习题1.19 ; ======================================================================;; Structure and Interpretation of Computer Programs; (trial answ...

weixin_30613727的博客 102

SICP 解题集

源网址:http://sicp.readthedocs.org/en/latest/# SICP 解题集 这个文档的目标是成为中文化的、完整的《计算机程序的构造和解释》一书的解题集。 这个解题集的特色是: 对于每道习题,除了习题答案之外,还给出习题的讲解和相关资料(如果有的话); 使用 MIT Scheme 作为编程环境,完全避免了代码不兼容的问题; 所有代

chinaliping的专栏 2261

可以查python题的_Python练习题3.4查找指定字符

原博文2020-04-17 09:26 −本题要求编写程序,从给定字符串中查找某指定的字符。输入格式:输入的第一行是一个待查找的字符。第二行是一个以回车结束的非空字符串(不超过80个字符)。输出格式:如果找到,在一行内按照格式“index = 下标”输出该字符在字符串中所对应的最大下标(下标从0开始);否则输出"Not Found"。代码如...相关推荐2019-12-18 16:30 −####...

weixin_39867125的博客 346
上一篇: bat批量修改后缀名
下一篇: 计算机程序解释与构造第二讲a
木颜飞翔
博客等级 码龄15年 4粉丝 11原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值