Documents

Write_Yourself_a_Scheme_in_48_Hours.pdf

Description
Description:
Categories
Published
of 138
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Share
Transcript
  Write Yourself a Scheme in 48 Hours An Introduction to Haskell through Example by Wikibooks contributors srcinally by Jonathan Tang Created on Wikibooks,the open content textbooks collection.  Copyright c   2007 Jonathan Tang & Wikibooks contributors.Permission is granted to copy, distribute and/or modify this document underthe terms of the GNU Free Documentation License, Version 1.2 or any later ver-sion published by the Free Software Foundation; with no Invariant Sections, noFront-Cover Texts, and no Back-Cover Texts. A copy of the license is includedin the section entitled “GNU Free Documentation License”.  Contents Overview v1 First Steps 1 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2 Parsing 5 Writing a Simple Parser . . . . . . . . . . . . . . . . . . . . . . . . . . 5Whitespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Return Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Recursive Parsers: Adding lists, dotted lists, and quoted datums . . . 13Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3 Evaluation, Part 1 17 Beginning the Evaluator . . . . . . . . . . . . . . . . . . . . . . . . . . 17Beginnings of an Evaluator: Primitives . . . . . . . . . . . . . . . . . . 20Adding Basic Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . 23Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 4 Error Checking and Exceptions 295 Evaluation, Part 2 37 Additional Primitives: Partial Application . . . . . . . . . . . . . . . . 37Conditionals: Pattern Matching 2 . . . . . . . . . . . . . . . . . . . . . 42List Primitives:  car ,  cdr , and  cons  . . . . . . . . . . . . . . . . . . . 42 Equal?  and Weak Typing: Heterogenous Lists . . . . . . . . . . . . . 48Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 6 Building a REPL 577 Adding Variables and Assignment 658 Defining Scheme Functions 779 Creating IO Primitives 87 i  10 Towards a Standard Library 91Conclusion 101A Complete Parser 103B Answers to Exercises 113 Section 2.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Exercise 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Part 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Exercise 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Exercise 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114Exercise 4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114Exercise 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 C Document Information 117 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117PDF Information & History . . . . . . . . . . . . . . . . . . . . . . . . 117Document Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118Orignal Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118Wikibooks Changes . . . . . . . . . . . . . . . . . . . . . . . . . 118 D GNU Free Documentation License 119 1. APPLICABILITY AND DEFINITIONS . . . . . . . . . . . . . . . 1192. VERBATIM COPYING . . . . . . . . . . . . . . . . . . . . . . . . 1213. COPYING IN QUANTITY . . . . . . . . . . . . . . . . . . . . . . 1214. MODIFICATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . 1225. COMBINING DOCUMENTS . . . . . . . . . . . . . . . . . . . . . 1246. COLLECTIONS OF DOCUMENTS . . . . . . . . . . . . . . . . . 1247. AGGREGATION WITH INDEPENDENT WORKS . . . . . . . . 1258. TRANSLATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1259. TERMINATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12510. FUTURE REVISIONS OF THIS LICENSE . . . . . . . . . . . . 125ADDENDUM: How to use this License for your documents . . . . . . 126 Index 127 ii
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks
SAVE OUR EARTH

We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

More details...

Sign Now!

We are very appreciated for your Prompt Action!

x