实例介绍
Programming in Haskell 第二版 pdf
Programming in Haskell Second edition GRAHAM HUTTON University of nottingham CAMBRIDGE UNIVERSITY PRESS CAMBRIDGE UNIVERSITY PRESS University Printing I louse, Cambridge CB2 &BS, United Kingdom One liberty plaza, 20th Floor, New York, NY 10006, USA 477 Williamstown road. port melbourne vic 3207. australia 4843/24.2nd Floor. ans Delbi-110002 Indi 79 Anson Road, #06-04 06, Singapore 079906 Cambridge Univcrsity Press is part of thc Univcrsity of Cambridge It furthers the Universitys mission by disseminating knowledge in the pursuit of education, learning, and research at the highest international levels of excellence www.cambridge.org Informationonthistitlewww.cambridge.org/9781316626221 10.1017/9781316784099 Graham Hutton 2007. 2016 This publication is in copyright. Subject to statutory exception and to the provisions of relevant collective licensing agreements, no reproduction of any part may take place without the written permission of Cambridge Univcrsity press First published 2007 Second edition 2016 Printed in the United Kingdom by Clays, St Ives plc in 2016 A catalogue record for this publication is available from the British Library ISBN 978-1-316-62622-1 Paperback Cambridge Univcrsity Press has no responsibility for thc pcrsistcncc or accuracy of URLs for cxtcrnal or third- party Internet Web sites referred to in this publication, and does not guarantee that any content on such Web sites is, or will remain, accurate or appropriate For Annette. Callum and Tomn Contents Foreword Preface Part IBasic Concepts Introduction 1.1 Functions 2 Functional programming 1. fEatures of Haskell 1. hIstorical background 1.5A taste of haskell 1. 6 Chapter remarks 1.eXercises 2First steps 2. 1 Glasgow Haskell Compiler 2.iNstalling and starting 2.3 Standard prelude 2.4Function application 2.hAskell scripts 2.6 Chapter remarks 2.eXercises 3Types and classes 3.1 Basic concepts 3.2Basic types 3.3 List types 3.4Tuple types 3.5 Function typcs 3.6 Curried functions 3.pOlymorphic types 3. oVerloaded types 3.Basic classes 3.10Chaptcr remarks 3.exErcises 4Defining functions 4. 1New from old 4.2 Conditional expressions 4.3 Guarded equations 4.4Pattcrn matching 4.5Lambda expressions 4.oPerator sections 4.7 Chapter remarks 4. eXercises sList comprehensions 5. I Basic concepts 5.2 Guards 5. 3The zip function 5. 4 String comprehensions 5.5The Caesar cipher 5.6 Chapter remarks 5.eXercises rEcursive functions 6. I Basic concepts 6.2 Rccursion on lists 6. 3Multiple arguments 6. mUltiple recursion 6.5 Mutual recursion 6. 6Advice on recursion 6.7Chaptcr remarks 6.eXercises 7Higher-order functions 7.1 Basic concepts 7.pRocessing lists 7. 3The foldr function 7.4The foldl function 7. 5The composition operator 7.6 Binary string transmitter 7. vOting algorithms 7.8 Chapter remarks 7.eXercises dEclaring types and classes 8. 1Type declarations 8.2Data declarations 8.3Ncwtypc declarations 8.rEcursive types 8. 5 Class and instance declarations 8. tAutology checker 8.aBstract machinc 8.8 Chapter remarks 8.eXercises 9The countdown problem 9.1Introduction 9.2Arithmctic opcrators 9.nUmeric expressions 9.cOmbinatorial functions 9.5Formalising the problem 9.6Brute force solution 9.7Performance testing 9. 8 Combining generation and evaluation 9.eXploiting algebraic properties 9.10 Chapter remarks 9.1 eXercises Part IIGoing Further 10Interactive programming 10. 1The problem 10.2The solution 10.3 Basic actions 10. sEquencing 10.5Derived primitives 10. hAngman 10.Nim 10. 8Life 10.cHapter remarks 10. 10Exercises 1lUnbeatable tic-tac-toe 11. 1 Introduction 1. 2 Basic declarations 11. 3Grid utilities 11. dIsplaying a grid 11. mAking a move 1 1. rEading a number 11.7 Humanⅴ human 11 gAme trees 11.pRuning the tree 1. 1OMinimax algorithm II. I I Human vs computer 11 12 Chapter remarks 11.13 Exercises 12Monads and more 12. 1 Functors 12.2Applicatives 12. mOnads 12. cHapter remarks 12. eXercises 13Monadic parsing 13. 1What is a parser? 13.pArsers as functions 13. 3 Basic definitions 13. sEquencing parsers 13. 5 Making choices 13.dErived primitives 13. hAndling spacing 13. aRithmetic expressions 13.cAlculator 13. 10 Chapter remarks 13. 1 Exercises 14Foldables and friends 14. Monoids 14.2Foldables 14.3Traversables 14 cHapter remarks 14.5 Exercises 15Lazy evaluation 15.1Introduction 15.2 Evaluation strategies 15.tErmination 15. 4Numbcr of reductions 15. iNfinite structures 15.mOdular programming 15.sTrict application 15. Chapter remarks 15.9Excrciscs 16Reasoning about programs 16.1 Equational reasoning 16.rEasoning about Haskell 16. 3Simplc examples 16. iNduction on numbers 16. iNduction on lists 16. mAking append vanish 16. cOmpiler correctness 16.8 Chapter remarks 16.eXercises 17Calculating compilers 17.1 Introduction 17.2Syntax and semantics 17.aDding a stack 17.aDding a continuation 17. 5Defunctionalising 17.cOmbining the steps 17. cHapter remarks 17. 8Excrciscs Appendix selected solutions A l Introduction A. 2First steps A tYpes and classes A. 4Dcfining functions ASList comprehensions A rEcursive functions A.7Higher-order functions A dEclaring types and classe A9The countdown problem A iNTeractive programming A ll Unbeatable tic-tac-toe A 12 Monads and more A. 13Monadic parsing A. 14Foldables and friends A. 15Lazy evaluation A 1 rEasoning about programs A. 17 Calculating compilers Appendix bstandard prelude B. 1 Basic classes 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论