
Icon Programming Language Handbook Thomas W. Christopher Icon Programming Language Handbook Thomas W. Christopher Copyright © 1996. Thomas W. Christopher iii Icon Programming Language Handbook Beta edition. Copyright © 1996. Thomas W. Christopher Published by Dr. Thomas W. Christopher, Tools of Computing LLC, P. O. Box 6335, Evanston IL 60204-6335. Acknowledgment I wish to thank Patricia Guilbeault for her technical editing of this document. Todd Proebsting found several errors in the text and suggested improvements. Printed in the United States of America. iv Copyright © 1996. Thomas W. Christopher Table of Contents CONTENTS List of Figures. xi List of Tables . xiii Preface. xv Chapter 1 About Icon . 17 Chapter 2 Basics . 21 2.1 Compiling and running an Icon program . 21 2.2 Hello, world . 21 2.3 Declarations . 23 2.4 Exiting a program . 24 2.5 Elementary numbers . 25 2.5.1 Integer literals . 25 2.5.2 Selected integer operators. 25 2.6 Elementary strings . 25 2.6.1 String literals. 25 2.6.2 Selected string operators. 26 2.6.3 Subscripting strings. 26 2.6.4 Comparison operators . 28 2.7 Elementary control constructs . 28 2.7.1 If expressions . 28 2.7.2 While expressions . 28 2.7.3 Expression sequences . 29 2.8 Elementary generators . 29 2.9 Elementary lists. 29 2.9.1 List creation: list(n). 29 2.9.2 Subscripting lists. 30 2.9.3 List creation: [...]. 30 2.9.4 List creation: list(n,x) . 30 2.9.5 Selected list operators . 30 2.9.6 Differences between lists and strings . 32 2.9.7 Procedure main's parameter . 33 2.10 Records . 33 Chapter 3 Generators. 35 3.1 Expressions are generators . 35 3.2 Expression evaluation order . 35 Copyright © 1996. Thomas W. Christopher v Icon Programming Language Handbook 3.3 Every. 36 3.4 To . 36 3.5 To-by. 37 3.6 Element generation: !e . 37 3.7 Backtracking . 37 3.8 Failure . 38 3.9 Binary operators containing generators . 38 3.10 Arithmetic relational operators . 38 3.11 Conjunction: e1 & e2 . 39 3.12 Null and non-null tests: / x and \ x . 39 3.13 Coevaluation . 40 3.14 Alternation: e1 | e2 . 41 3.15 Sequence generation: seq(...) . 42 3.16 Repeated alternation: | e . 42 3.17 Limitation: e1 \ e2. 43 3.18 Idiom: generate and test . 44 Chapter 4 Control Constructs . 45 4.1 {e1; e2; ; en } . 45 4.2 every do. 45 4.3 if then else. 46 4.4 idiom : goal directed evaluation . 46 4.5 case of { } . 47 4.6 while do. 48 4.7 not . 49 4.8 idiom: write "all do" as "not any don't" . 49 4.9 until do . 50 4.10 repeat. 50 4.11 break . 51 4.12 next . 51 Chapter 5 Procedures. 53 5.1 Procedure calls . 53 5.2 Procedure declarations . 54 5.3 Idiom: default values for parameters . 55 5.4 Return . 55 5.5 Fail . 56 5.6 Suspend. 56 5.7 Initial. 57 5.8 String invocation. 58 5.9 Applying a procedure to a list. 58 5.10 Functions that apply to procedures . 59 Chapter 6 Strings and Character Sets . 61 6.1 String literals. 61 6.2 Positions in strings . 62 vi Copyright © 1996. Thomas W. Christopher Table of Contents 6.3 Subscripting . 62 6.4 Sectioning: subscripting ranges . 63 6.5 String operators. 64 6.6 String editing and conversion functions . 65 6.7 Idiom: map . 67 6.8 Character sets: cset . 68 6.8.1 Character set literals . 68 6.8.2 Character-set valued keywords. 68 6.8.3 Character set operators . 68 6.9 String scanning functions . 69 6.10 Automatic conversions . 72 6.11 Examples of strings. 72 6.11.1 Finding the rightmost occurrence . 72 6.11.2 Squeezing whitespace . 72 6.11.3 Converting two hex digits to a character . 73 6.11.4 Converting a character to two hex digits . 73 6.11.5 Removing backspaces. 73 6.11.6 Generating character set tests for C . 74 6.11.7 Generate identifiers. 74 6.11.8 Primes sieve . 75 6.12 Scanning Strings . 75 6.12.1 Scanning . 75 6.12.2 Functions tab and move . 76 6.12.3 String scanning functions revisited. 76 6.12.4 Matching a string, = e . 77 6.12.5 Scanning with assignment, ?:= . 78 6.12.6 Testing &pos, pos(i) . 78 6.12.7 Example . 78 6.13 Regular expressions . 78 6.13.1 findre . 79 6.13.2 regexpr . 80 Chapter 7 Arithmetic . 83 7.1 Numeric literals. 83 7.2 Operators. 84 7.3 Large integers . ..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages226 Page
-
File Size-