资源描述:
《DIT027-SampleExam》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、EXAMDistributedFault-tolerantProgrammingDIT027Day:SampleExamTime:??-??Place:N/A•Responsible:HansSvensson•Result:Notapplicable•Aids:None•Grade:Thereare6assignments(with15+24+16+15+25+5=100points);atotalofatleast50pointsisapass(G)andatotalofatleast75pointsisapassw.distinction(VG).Pleas
2、ereadthefollowingguidelinescarefully:•Pleasereadthroughallassignmentsbeforestartworkingontheanswers•AnswersshouldbegiveninEnglish•Begineachassignmentonanewsheet•WriteyouranonymousIDoneachsheet•Writeclearly;unreadable==wrong!•Fullmarksaregiventosolutionsthatareshort,elegant,andcorrect
3、•Lessmarksaregiventounnecessarilycomplicatedorunstructuredsolutions•Don'tforgettowritecommentswithyourcode•YouareallowedtousestandardErlangfunctionsandlibraries,ifnothingisexplicitlymentionedintheproblemdescription•Theexactsyntaxisnotcrucial,youwillnotbepunishedformissingforexampleap
4、arenthesisoracomma.GoodLuck!Problem1–Patternmatching(total15p)Inthisassignmentyouaregivenfivepatternmatchingexpressions.Ifmatchingsucceeds,whatarethevaluesoftheboundvariables?Ifmatchingdoesnotsucceed,explainwhy.(3p)QuestionA{A,B}={12,[1,2,3]}.(3p)QuestionB[X,Y,stop
5、Z]=[1
6、[5
7、[stop,3,4
8、]]].(3p)QuestionC{{_,X},{_,Y}}={{5,1},{1,5}}.(3p)QuestionD{{A,B},[A]}={{1,2},[2]}.(3p)QuestionE{person,Gender,Name,24}={person,female,”Eva”,24}.Problem2–Understandingsequentialcode(total24p)Inthisassignmentyouaregiventhecodeofthemoduleexam(listedbelow).Firstly,youhavetoexplaintheresu
9、ltofevaluatingthefollowingexpressions:(3p)QuestionAexam:f1(1,[2,3,1,4]).(3p)QuestionBexam:f1(1,[1,2,3,1,4]).(3p)QuestionCexam:f1(6,[1,aap,2,1]).(3p)QuestionDexam:f2([aap,noot,mies],[1,2,3]).(3p)QuestionEexam:f2([[1,2],[2,3]],[1,2]).(3p)QuestionFexam:f2([1,2,3],[aap]).Secondly,youhave
10、toexplaintheerrormessageproducedwhenevaluatingthefollowingexpressions:(3p)QuestionGexam:f1(3,[1,2
11、3]).**exceptionerror:nofunctionclausematchingexam:f1(3,3)infunctionexam:f1/2(3p)QuestionHexam:f2([1,2,3],[3,2,1,0]).**exceptionerror:nofunctionclausematchingexam:f2([],[0])infunctionexam
12、:f2/2Theexam