- 2024-11-19sicp每日一题[2.82]
Exercise2.82Showhowtogeneralizeapply-generictohandlecoercioninthegeneralcaseofmultiplearguments.Onestrategyistoattempttocoercealltheargumentstothetypeofthefirstargument,thentothetypeofthesecondargument,andsoon.
- 2024-11-17sicp每日一题[2.80]
Exercise2.80Defineagenericpredicate=zero?thattestsifitsargumentiszero,andinstallitinthegenericarithmeticpackage.Thisoperationshouldworkforordinarynumbers,rationalnumbers,andcomplexnumbers.这道题更简单,直接与0相比较就行,以下
- 2024-11-16sicp每日一题[2.79]
Exercise2.79Defineagenericequalitypredicateequ?thatteststheequalityoftwonumbers,andinstallitinthegenericarithmeticpackage.Thisoperationshouldworkforordinarynumbers,rationalnumbers,andcomplexnumbers.这道题也挺简单的,分别在
- 2024-11-15sicp每日一题[2.78]
Exercise2.78Theinternalproceduresinthescheme-numberpackageareessentiallynothingmorethancallstotheprimitiveprocedures+,-,etc.Itwasnotpossibletousetheprimitivesofthelanguagedirectlybecauseourtype-tagsystemrequiresthat
- 2024-11-14sicp每日一题[2.77]
Exercise2.77LouisReasonertriestoevaluatetheexpression(magnitudez)wherezistheobjectshowninFigure2.24.Tohissurprise,insteadoftheanswershegetsanerrormessagefromapply-generic,sayingthereisnomethodfortheoperationmagni
- 2024-11-11sicp每日一题[2.74]
Exercise2.74InsatiableEnterprises,Inc.,isahighlydecentralizedconglomeratecompanyconsistingofalargenumberofindependentdivisionslocatedallovertheworld.Thecompany’scomputerfacilitieshavejustbeeninterconnectedbymeansofacle
- 2024-11-09sicp每日一题[2.73]
最近状态不太好,再加上2.73前面的内容有点多,学的有点吃力,所以昨天就没做。。Exercise2.73Section2.3.2describedaprogramthatperformssymbolicdifferentiation:(define(derivexpvar)(cond((number?exp)0)((variable?exp)(if(same-va
- 2024-11-07sicp每日一题[2.72]
Exercise2.72ConsidertheencodingprocedurethatyoudesignedinExercise2.68.Whatistheorderofgrowthinthenumberofstepsneededtoencodeasymbol?Besuretoincludethenumberofstepsneededtosearchthesymbollistateachnodeencounter
- 2024-11-06sicp每日一题[2.71]
Exercise2.71SupposewehaveaHuffmantreeforanalphabetofnsymbols,andthattherelativefrequenciesofthesymbolsare1,2,4,...,2n1.Sketchthetreeforn=5;forn=10.Insuchatree(forgeneraln)howmanybitsarerequiredtoencode
- 2024-11-05sicp每日一题[2.70]
Exercise2.70Thefollowingeight-symbolalphabetwithassociatedrelativefrequencieswasdesignedtoefficientlyencodethelyricsof1950srocksongs.(Notethatthe“symbols”ofan“alphabet”neednotbeindividualletters.)A2GET2SHA3
- 2024-11-04sicp每日一题[2.69]
Exercise2.69Thefollowingproceduretakesasitsargumentalistofsymbol-frequencypairs(wherenosymbolappearsinmorethanonepair)andgeneratesaHuffmanencodingtreeaccordingtotheHuffmanalgorithm.(define(generate-huffman-treepairs)
- 2024-11-02sicp每日一题[2.66]
Exercise2.66Implementthelookupprocedureforthecasewherethesetofrecordsisstructuredasabinarytree,orderedbythenumericalvaluesofthekeys.这道题还是挺简单的,由于是有序的二叉树,所以可以先比较根与要查找的数字的大小,如果相等就查到了;如果根
- 2024-10-31sicp每日一题[2.63-2.64]
Exercise2.63Eachofthefollowingtwoproceduresconvertsabinarytreetoalist.(define(tree->list-1tree)(if(null?tree)'()(append(tree->list-1(left-branchtree))(cons(entrytree)
- 2024-10-28sicp每日一题[2.60]
Exercise2.60Wespecifiedthatasetwouldberepresentedasalistwithnoduplicates.Nowsupposeweallowduplicates.Forinstance,theset{1,2,3}couldberepresentedasthelist(2321322).Designprocedureselementof-set?,adjoin-set,unio
- 2024-10-26sicp每日一题[2.58]
Exercise2.58Supposewewanttomodifythedifferentiationprogramsothatitworkswithordinarymathematicalnotation,inwhich+and*areinfixratherthanprefixoperators.Sincethedifferentiationprogramisdefinedintermsofabstractdata,we
- 2024-10-24sicp每日一题[2.56]
Exercise2.56Showhowtoextendthebasicdifferentiatortohandlemorekindsofexpressions.Forinstance,implementthedifferentiationruled(x^n)/dx=nx^(n-1)byaddinganewclausetothederivprogramanddefiningappropriateproceduresexpone
- 2024-10-22sicp每日一题[2.52]
Exercise2.52MakechangestothesquarelimitofwaveshowninFigure2.9byworkingateachofthelevelsdescribedabove.Inparticular:a.AddsomesegmentstotheprimitivewavepainterofExercise2.49(toaddasmile,forexample).b.Changethe
- 2024-10-21sicp每日一题[2.51]
Exercise2.51Definethebelowoperationforpainters.belowtakestwopaintersasarguments.Theresultingpainter,givenaframe,drawswiththefirstpainterinthebottomoftheframeandwiththesecondpainterinthetop.Definebelowintwodiffere
- 2024-10-20sicp每日一题[2.50]
Exercise2.50Definethetransformationflip-horiz,whichflipspaintershorizontally,andtransformationsthatrotatepainterscounterclockwiseby180degreesand270degrees.这道题挺有意思的,搞明白这道题就明白了frame的3个点的位置。如上图所示,为了更好
- 2024-10-19sicp每日一题[2.49]
Exercise2.49Usesegments->paintertodefinethefollowingprimitivepainters:a.Thepainterthatdrawstheoutlineofthedesignatedframe.b.Thepainterthatdrawsan“X”byconnectingoppositecornersoftheframe.c.Thepainterthatdrawsad
- 2024-10-18sicp每日一题[2.48]
Exercise2.48Adirectedlinesegmentintheplanecanberepresentedasapairofvectors—thevectorrunningfromtheorigintothestart-pointofthesegment,andthevectorrunningfromtheorigintotheend-pointofthesegment.Useyourvectorrepre
- 2024-10-17sicp每日一题[2.47]
Exercise2.47Herearetwopossibleconstructorsforframes:(define(make-frameoriginedge1edge2)(listoriginedge1edge2))(define(make-frameoriginedge1edge2)(consorigin(consedge1edge2)))Foreachconstructorsupplytheappropriate
- 2024-10-14sicp每日一题[2.44]
我在这一章遇到了一个大问题,就是书上用的那些函数beside,wave,flip-vert我统统用不了。我用的是DrRacket这个软件,在网上查了半天,终于找到了解决办法。首先是官方教程,在DrRacket中依次打开File->PackageManager...,在弹出的页面中"DoWhatIMean"菜单页的输入:sicp,
- 2024-10-13sicp每日一题[2.43]
Exercise2.43LouisReasonerishavingaterribletimedoingExercise2.42.Hisqueensprocedureseemstowork,butitrunsextremelyslowly.(Louisneverdoesmanagetowaitlongenoughforittosolveeventhe6×6case.)WhenLouisasksEvaLuAtorf