欢迎来到天天文库
浏览记录
ID:39988455
大小:185.52 KB
页数:5页
时间:2019-07-16
《Scheme_9_Streams1》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、StreamsinScheme(A&S3.5)•Consideraprocessthatconsumesitsinputsoneatatime–i.e.sequentially•onlypartofaninputsequenceneedstobeinexistenceforitsconsumingprocesstobeabletouseit.StateandStreams•structureswiththispropertyarecalledstreamsinScheme•Inabstractterms,astreamissomething
2、whichhasa–headwhichisavalueandaAbelson&Sussman&Sussmansections:–tailwhichisastream(3.4),3.5•becauseweaccessthestreamoneitematatime,thetailneednotbefullyevaluated•Thus,weexplorealternativemodesofevaluation:non-strictandlazyevaluation•Also,streamsprovideanimplicitnotionofsta
3、teStreams…Streams…©UniversityofAdelaide/1.0Scheme-9/Slide1©UniversityofAdelaide/1.0Scheme-9/Slide2ObjectsrepresentedasstreamsaGISprocessingchain•Variousobjectscanberepresentedasstreams.•Examples–Asequentialfile»Headisthefile“window”»TailistherestofthefileConversion–Thevalu
4、esproducedbyaniterationRectification»Headisthecurrentvalue.Conversion»Tailistheproceduralobjectcapableofproducingtherestofthestream–Datastreamsinsatellitedataoraudio/visualapplicationsStreams…Streams…©UniversityofAdelaide/1.0Scheme-9/Slide3©UniversityofAdelaide/1.0Scheme-9
5、/Slide4StreamsinSchemeImplementingstreamsinScheme(car(cdr(filterprime?(enumerate-interval100001000000))))•WewanttorepresentstreamevaluationinScheme..•Thestreamoperationsarecons-streamheadtail[10007,10009,…][10000…10^6]EnumFilter•Bookusestheequivalentterms:prime?10000cons-s
6、treamstream-carstream-cdr10^6•Wecouldtryrepresentingastreamasalistso:cons-streamiscons•Usingstandardlistbuilding/decompositionoperatorsisinadequate.headiscar–Theseoperatorsforcetheentireinputlisttobebuiltwheneverwepassastreaminasanargument.tailiscdr–i.e.thetailisevaluated.
7、empty-streamisnil–Wewouldpreferittobeleftun-evaluated.•Usingjustcons,car,andcdrprecludestheuseofinfinitestreams.•Thisisinadequate-forexample,considerastreamofprime•Usingonlyfinitestreamsisinefficient.numbers…•Sowelookforanalternative.Streams…Streams…©UniversityofAdelaide/1
8、.0Scheme-9/Slide5©UniversityofAdelaide/1.0Scheme-9/Slide6Page1ImplementingStreamsinScheme
此文档下载收益归作者所有
点击更多查看相关文章~~