Views
3 years ago

Introduction to Programming

Introduction to Programming

Introduction to

command the brilliance of a thousand mathematicians Introductory Programming Guide

  • Page 2 and 3: Maple 8 Introductory Programming Gu
  • Page 4 and 5: Preface • iii Audience As a Maple
  • Page 6 and 7: Contents 1 Introduction to Programm
  • Page 8 and 9: Contents • vii Displaying Large E
  • Page 10 and 11: Contents • ix Procedure Body Stat
  • Page 12 and 13: Contents • xi 8.5 Managing Resour
  • Page 14 and 15: 1 Introduction to Programming in Ma
  • Page 16 and 17: 1.2 Maple Statements • 3 This pro
  • Page 18 and 19: 1.3 Procedures • 5 a := 103993 33
  • Page 20 and 21: 1.3 Procedures • 7 This procedure
  • Page 22 and 23: 1.3 Procedures • 9 • Omit the s
  • Page 24 and 25: 1.3 Procedures • 11 > c; 1 This g
  • Page 26 and 27: 1.5 Troubleshooting • 13 • Hold
  • Page 28 and 29: 1.5 Troubleshooting • 15 Invalid,
  • Page 30 and 31: 1.6 Exercises • 17 2 > evalb(x=2)
  • Page 32 and 33: 2 Maple Language Elements Before pr
  • Page 34 and 35: 2.2 Tokens • 21 Table 2.2 Reserve
  • Page 36 and 37: 2.2 Tokens • 23 Table 2.4 Program
  • Page 38 and 39: 2.2 Tokens • 25 symbol Because th
  • Page 40 and 41: 2.2 Tokens • 27 The concatenation
  • Page 42 and 43: 2.2 Tokens • 29 > cat(a, 4); 24 A
  • Page 44 and 45: 2.2 Tokens • 31 Table 2.5 Initial
  • Page 46 and 47: 2.2 Tokens • 33 10 > evalf(2/13);
  • Page 48 and 49: 2.2 Tokens • 35 Strings A string
  • Page 50 and 51: 2.2 Tokens • 37 “def” Alterna
  • Page 52 and 53:

    2.2 Tokens • 39 > n := 4: "p" ||

  • Page 54 and 55:

    2.2 Tokens • 41 number indicates

  • Page 56 and 57:

    2.3 Using Special Characters • 43

  • Page 58 and 59:

    2.3 Using Special Characters • 45

  • Page 60 and 61:

    2.4 Types and Operands • 47 , Use

  • Page 62 and 63:

    2.4 Types and Operands • 49 true

  • Page 64 and 65:

    2.5 Troubleshooting • 51 true > n

  • Page 66 and 67:

    2.5 Troubleshooting • 53 The bina

  • Page 68 and 69:

    2.7 Conclusion 2.7 Conclusion • 5

  • Page 70 and 71:

    3 Maple Expressions and Statements

  • Page 72 and 73:

    3.2 Expressions • 59 These are im

  • Page 74 and 75:

    3.2 Expressions • 61 In Maple, th

  • Page 76 and 77:

    3.2 Expressions • 63 natural.natu

  • Page 78 and 79:

    3.2 Expressions • 65 You can also

  • Page 80 and 81:

    3.2 Expressions • 67 Table 3.1 Ty

  • Page 82 and 83:

    3.2 Expressions • 69 • The type

  • Page 84 and 85:

    3.2 Expressions • 71 distributes

  • Page 86 and 87:

    ⎡ ⎣ ⎤ 10 0 ⎦ 20 3.2 Express

  • Page 88 and 89:

    3.2 Expressions • 75 The ditto op

  • Page 90 and 91:

    3.2 Expressions • 77 The type of

  • Page 92 and 93:

    3.2 Expressions • 79 > 1/2 mod 5;

  • Page 94 and 95:

    3.2 Expressions • 81 2 x + 6 y =

  • Page 96 and 97:

    3.2 Expressions • 83 > is( 3 2>3

  • Page 98 and 99:

    3.2 Expressions • 85 and false tr

  • Page 100 and 101:

    3.2 Expressions • 87 Table 3.4 Op

  • Page 102 and 103:

    3.2 Expressions • 89 T := table([

  • Page 104 and 105:

    3.2 Expressions • 91 s := 2, 3 >

  • Page 106 and 107:

    h := proc(t) t ∗ (t − 1) end pr

  • Page 108 and 109:

    3.3 Using Expressions • 95 Table

  • Page 110 and 111:

    3.3 Using Expressions • 97 Using

  • Page 112 and 113:

    3.3 Using Expressions • 99 a := 1

  • Page 114 and 115:

    3.3 Using Expressions • 101 eval(

  • Page 116 and 117:

    3.3 Using Expressions • 103 to ma

  • Page 118 and 119:

    3.3 Using Expressions • 105 false

  • Page 120 and 121:

    type( exp(x), specfunc(name, exp) )

  • Page 122 and 123:

    name := expr; (name1, ..., namen) :

  • Page 124 and 125:

    3.4 Statements • 111 One method o

  • Page 126 and 127:

    3.4 Statements • 113 For more inf

  • Page 128 and 129:

    3.4 Statements • 115 total := 0 i

  • Page 130 and 131:

    3.5 Troubleshooting • 117 The use

  • Page 132 and 133:

    3.6 Exercises • 119 To avoid this

  • Page 134 and 135:

    4 Basic Data Structures Maple suppo

  • Page 136 and 137:

    4.1 Sets • 123 Testing set equali

  • Page 138 and 139:

    4.2 Lists • 125 > [a, 1, b, 2]; [

  • Page 140 and 141:

    4.2 Lists • 127 > L1 := [a,b,c];

  • Page 142 and 143:

    4.2 Lists • 129 Table 4.1 Sorting

  • Page 144 and 145:

    4.3 Tables • 131 zip( f, L1, L2,

  • Page 146 and 147:

    4.3 Tables • 133 > T3[shirt,M]; 8

  • Page 148 and 149:

    4.3 Tables • 135 > keyvalues := p

  • Page 150 and 151:

    4.3 Tables • 137 Table 4.2 Table

  • Page 152 and 153:

    4.4 arrays and Arrays • 139 In th

  • Page 154 and 155:

    4.4 arrays and Arrays • 141 [ ] 1

  • Page 156 and 157:

    4.4 arrays and Arrays • 143 Manip

  • Page 158 and 159:

    4.4 arrays and Arrays • 145 Table

  • Page 160 and 161:

    4.4 arrays and Arrays • 147 Copyi

  • Page 162 and 163:

    4.4 arrays and Arrays • 149 > A8;

  • Page 164 and 165:

    4.5 Selecting Elements from a Data

  • Page 166 and 167:

    4.5 Selecting Elements from a Data

  • Page 168 and 169:

    4.5 Selecting Elements from a Data

  • Page 170 and 171:

    4.7 Other Maple Data Structures •

  • Page 172 and 173:

    4.7 Other Maple Data Structures •

  • Page 174 and 175:

    4.8 Troubleshooting 4.8 Troubleshoo

  • Page 176 and 177:

    4.9 Exercises • 163 > A := Array(

  • Page 178 and 179:

    5 Flow Control In the Maple program

  • Page 180 and 181:

    5.1 Selection and Conditional Execu

  • Page 182 and 183:

    5.1 Selection and Conditional Execu

  • Page 184 and 185:

    5.2 Repetition • 171 for name in

  • Page 186 and 187:

    5.2 Repetition • 173 When the by

  • Page 188 and 189:

    5.2 Repetition • 175 L := [7, 2,

  • Page 190 and 191:

    5.2 Repetition • 177 The break st

  • Page 192 and 193:

    [f(a), f(b), f(c)] 5.3 Looping Comm

  • Page 194 and 195:

    zip( (x,y) -> x+y, [a,b,c,d,e,f], [

  • Page 196 and 197:

    5.3 Looping Commands • 183 The re

  • Page 198 and 199:

    5.4 Troubleshooting • 185 > sum(k

  • Page 200 and 201:

    5.4 Troubleshooting • 187 > for i

  • Page 202 and 203:

    5.5 Exercises 5.5 Exercises • 189

  • Page 204 and 205:

    6 Maple Procedures A Maple procedur

  • Page 206 and 207:

    6.1 Defining a Procedure • 193 Ex

  • Page 208 and 209:

    F := proc() “Hello World” end p

  • Page 210 and 211:

    6.2 Procedure Components • 197 In

  • Page 212 and 213:

    cube := proc(x::anything, y::name)

  • Page 214 and 215:

    6.2 Procedure Components • 201 Er

  • Page 216 and 217:

    6.2 Procedure Components • 203 Wi

  • Page 218 and 219:

    6.2 Procedure Components • 205 pr

  • Page 220 and 221:

    6.2 Procedure Components • 207 ve

  • Page 222 and 223:

    6.2 Procedure Components • 209 If

  • Page 224 and 225:

    6.2 Procedure Components • 211 Th

  • Page 226 and 227:

    6.2 Procedure Components • 213 >

  • Page 228 and 229:

    6.3 Procedure Simplification • 21

  • Page 230 and 231:

    GCD := proc(a::integer, b::integer)

  • Page 232 and 233:

    6.4 Procedure Return Values • 219

  • Page 234 and 235:

    6.4 Procedure Return Values • 221

  • Page 236 and 237:

    6.5 Documenting Your Procedures •

  • Page 238 and 239:

    6.6 Saving and Retrieving Procedure

  • Page 240 and 241:

    6.7 Viewing Maple Library Source Co

  • Page 242 and 243:

    interface(verboseproc=1): 6.8 Alter

  • Page 244 and 245:

    6.8 Alternate Methods for Defining

  • Page 246 and 247:

    6.8 Alternate Methods for Defining

  • Page 248 and 249:

    6.9 The Procedure Object • 235 Ta

  • Page 250 and 251:

    6.10 Using Data Structures to Solve

  • Page 252 and 253:

    6.10 Using Data Structures to Solve

  • Page 254 and 255:

    6.10 Using Data Structures to Solve

  • Page 256 and 257:

    6.10 Using Data Structures to Solve

  • Page 258 and 259:

    6.10 Using Data Structures to Solve

  • Page 260 and 261:

    6.10 Using Data Structures to Solve

  • Page 262 and 263:

    6.11 Troubleshooting • 249 > T[Wa

  • Page 264 and 265:

    6.11 Troubleshooting • 251 Implic

  • Page 266 and 267:

    6.12 Exercises • 253 t 2 6.12 Exe

  • Page 268 and 269:

    7 Input and Output Input and output

  • Page 270 and 271:

    7.1 Screen and Keyboard I/O • 257

  • Page 272 and 273:

    7.1 Screen and Keyboard I/O • 259

  • Page 274 and 275:

    7.1 Screen and Keyboard I/O • 261

  • Page 276 and 277:

    7.1 Screen and Keyboard I/O • 263

  • Page 278 and 279:

    7.1 Screen and Keyboard I/O • 265

  • Page 280 and 281:

    7.2 Standard Disk I/O • 267 For m

  • Page 282 and 283:

    7.2 Standard Disk I/O • 269 read

  • Page 284 and 285:

    7.2 Standard Disk I/O • 271 > int

  • Page 286 and 287:

    7.2 Standard Disk I/O • 273 > rea

  • Page 288 and 289:

    7.2 Standard Disk I/O • 275 8 6 4

  • Page 290 and 291:

    7.3 Troubleshooting • 277 common

  • Page 292 and 293:

    7.5 Conclusion 7.5 Conclusion • 2

  • Page 294 and 295:

    8 Debugging and Efficiency New prog

  • Page 296 and 297:

    2 for i from 2 to n do 3 flags[i] :

  • Page 298 and 299:

    8.1 A Tutorial Example • 285 To r

  • Page 300 and 301:

    8.1 A Tutorial Example • 287 siev

  • Page 302 and 303:

    8.1 A Tutorial Example • 289 The

  • Page 304 and 305:

    8.1 A Tutorial Example • 291 disc

  • Page 306 and 307:

    8.2 Maple Debugger Commands • 293

  • Page 308 and 309:

    8.2 Maple Debugger Commands • 295

  • Page 310 and 311:

    8.2 Maple Debugger Commands • 297

  • Page 312 and 313:

    stopwhen( globalVariableName ); sto

  • Page 314 and 315:

    8.2 Maple Debugger Commands • 301

  • Page 316 and 317:

    8.2 Maple Debugger Commands • 303

  • Page 318 and 319:

    8.2 Maple Debugger Commands • 305

  • Page 320 and 321:

    8.2 Maple Debugger Commands • 307

  • Page 322 and 323:

    8.2 Maple Debugger Commands • 309

  • Page 324 and 325:

    8.2 Maple Debugger Commands • 311

  • Page 326 and 327:

    8.3 Detecting Errors • 313 The pr

  • Page 328 and 329:

    8.3 Detecting Errors • 315 The am

  • Page 330 and 331:

    8.3 Detecting Errors • 317 tracel

  • Page 332 and 333:

    8.3 Detecting Errors • 319 true I

  • Page 334 and 335:

    8.3 Detecting Errors • 321 Raisin

  • Page 336 and 337:

    try tryStatSeq catch catchStrings :

  • Page 338 and 339:

    8.3 Detecting Errors • 325 not su

  • Page 340 and 341:

    8.4 Creating Efficient Programs •

  • Page 342 and 343:

    st := time(): ... statements to be

  • Page 344 and 345:

    8.5 Managing Resources • 331 By s

  • Page 346 and 347:

    8.6 Exercises • 333 • kernelopt

  • Page 348 and 349:

    9 Introduction to Maplets A maplet

  • Page 350 and 351:

    9.1 Maplet Applications • 337 Int

  • Page 352 and 353:

    9.3 Terminology • 339 Elements El

  • Page 354 and 355:

    9.4 Elements • 341 CheckBox Displ

  • Page 356 and 357:

    9.4 Elements • 343 ListBox A list

  • Page 358 and 359:

    9.4 Elements • 345 Plotter Displa

  • Page 360 and 361:

    9.4 Elements • 347 TextBox A mult

  • Page 362 and 363:

    9.4 Elements • 349 Layout Element

  • Page 364 and 365:

    9.4 Elements • 351 The default po

  • Page 366 and 367:

    9.4 Elements • 353 Shutdown Close

  • Page 368 and 369:

    9.4 Elements • 355 FileDialog A s

  • Page 370 and 371:

    9.4 Elements • 357 Other Elements

  • Page 372 and 373:

    9.5 Example Maplets • 359 Window

  • Page 374 and 375:

    9.5 Example Maplets • 361 Creatin

  • Page 376 and 377:

    9.7 Running a Maplet • 363 Print

  • Page 378 and 379:

    9.9 After Reading This Chapter •

  • Page 380 and 381:

    Index !, 23, 47, 76, 87 $, 22, 23,

  • Page 382 and 383:

    Index • 369 conditional execution

  • Page 384 and 385:

    Index • 371 evalb, 16 Evaluate, 3

  • Page 386 and 387:

    Index • 373 about, 2 code viewing

  • Page 388 and 389:

    Index • 375 nullary operators, 21

  • Page 390 and 391:

    Index • 377 formal parameters, 19

  • Page 392 and 393:

    Index • 379 Set, 363 set operator

  • Page 394 and 395:

    Index • 381 nonnegint, 48 nonposi

  • Page 396:

    Waterloo Maple Inc. 57 Erb Street W

Introduction to SWI-Prolog & Its Graphical Tracer Programming ...
A practical introduction to Pascal programming language - GIARA
INFO 1103 Introduction to Programming Sample Quiz 1 (week 5 ...
Introduction to functional programming
CS11002 Programming and Data Structures Spring 2008 Introduction
Parlante's Unix Programming Tools - Faculty.rmc.edu
ABAP Objects An Introduction to Programming SAP ... - Trainning
Introduction Mini Brochure - Smith Flow Control Ltd
Mircea's Introduction - GK-12 Program at the University of Houston
Introduction to Programs at the Guam SBDC, MAY 2012
Introduction to the Advanced Calculation Engine Guide - Trayport
An Interactive Introduction to OpenGL Programming
Chapter 4: Programming with MATLAB - FET
Introduction to MATLAB 7 for Engineers Chapter 1 An ... - FET
Introduction to DCBPW 2012 Brock Wilcox awwaiid@thelackthereof ...
Kitchen Introduction
Introduction to the MFT Program at K-State (Adobe Acrobat)
e77-2: introduction to computer programming for scientists
A Practical Introduction to Unix - School of Information Sciences ...
An Introduction to Finite Element Method