F.G.H. 5/16/85 LispCourse #28: Type Checking; Strings; Arrays LispCourse #28: Type Checking; Strings; Arrays Type Checking in Interlisp The Concept of Type Checking Many programming languages insist that each parameter to a function be typed › i.e., that it be declared to be a variable whose value is a given type of data (e.g., an litatom, a number, or a list). In these languages when you call a function, the language checks the type of each argument in the argument list to make sure that it matches the declared type of each parameter in the parameter list. An error results if you call a function with arguments of the wrong type. Example from PASCAL: function SumOfSquares (X: INTEGER, Y: INTEGER): INTEGER BEGIN SumOfSquares := (X * X) + (Y * Y) END This PASCAL function definition says that SumOfSquares is a function that takes two integer arguments and returns an integer. Therefore: (SumOfSquares 2 3) is okay But (SumOfSquares "Foo" 4) causes an immediate error because "Foo" is not an integer, but a string of characters. The error will say something like "First argument to SumOfSquares is not an integer as required." Note that (SumOfSquares 1.234 4) also causes an error because 1.234 is not an integer, but a floating point number. Interlisp does not do this type checking. You do not have to declare the expected type of a parameter in your function definitions AND Interlisp does not check the type of the arguments when you call the function. Example: (DEFINEQ (SumOfSquares (LAMBDA (X Y) (PLUS (TIMES X X)(TIMES Y Y)))))) (SumOfSquares 2 3) works fine and returns an integer, 13. (SumOfSquares 1.234 4) also works fine, but returns a floating point number 17.52276. But, (SumOfSquares 'Foo 4) will cause an error (i.e., a BREAK). The error will occur somewhere deep inside the SumOfSquares function and the error message will not reflect the real problem œ i.e., that the argument to SumOfSquares was of the wrong type. ůç"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙â"""""ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙ýUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUhˆˆˆˆˆ€ˆüż°Á˙}÷˙÷˙˙ţŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞčˆˆˆˆˆ€"}˙ßw˙>˙}÷˙÷˙˙ţŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞâ""""""}˙î÷˙}÷˙˙÷˙˙ýUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUb"""""ˆý˙î÷ţ˙şďh~‡šÝUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUhˆˆˆˆˆ€ˆý˙ő÷ţ˙˙şďg˝ç{šŢŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞčˆˆˆˆˆ€"|űđ˙˙şďoŰöýśŢŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞâ""""""}˙ő÷ţ˙˙×_oŰöýÖ˝UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUb"""""ˆý˙î÷ţ˙×_oŰöýÖ˝UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUhˆˆˆˆˆ€ˆý˙î÷˙×_oŰöýď~ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞčˆˆˆˆˆ€"}˙ßw˙>˙ďżoÝç{ď~ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞâ""""""|ż°Á˙ďżoއď}UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUb"""""ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙ýUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUhˆˆˆˆˆ€ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙ţŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞčˆˆˆˆˆ€"˙˙˙˙˙˙˙˙˙˙˙˙˙ţŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞâ""""""˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙â"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`!b""""""` !b"""""ˆŕ‚ @Ahˆˆˆˆˆ€ˆăâ>|@ŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕ€hˆˆˆˆˆ€"aÇŔŕ 0@b""""""b @"@P@b"""""ˆâ‚"DŮÄF‘XpŕP hˆˆˆˆˆ€ˆăŔ„DŠ ‘d‰" hˆˆˆˆˆ€"b!ˆDŠˆ‘@řŔ" b""""""b!"DŠH‘"@€ "ř b"""""ˆâ""LŠI“"@‰" hˆˆˆˆˆ€ˆáÂ4¨á†@pŕ@hˆˆˆˆˆ€"`€@b""""""`€€b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"b#ˆ€"D‰óÇxpb""""""c$L€2DŮ!€Dˆb"""""ˆă$L€2DŮ!€Dˆhˆˆˆˆˆ€ˆâ¤J€*DŠăÁx€hˆˆˆˆˆ€"b¤JŸ*DŠ"P¸b""""""bdI€&DŠA€>Hˆb"""""ˆâdI€&DŠ!€"Dˆhˆˆˆˆˆ€ˆâ#ˆ€"8‰ň#‡"Dphˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"cŕb""""""bb"""""ˆâ‡hˆˆˆˆˆ€ˆăÄH€hˆˆˆˆˆ€"bH€b""""""bH€b"""""ˆâH€hˆˆˆˆˆ€ˆâ‡hˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙â"""""ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙興ˆˆˆ€ˆˆˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙Ȁ"""/˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙úŞŞŞŞŞŞŞŞŞŞŞŞż˙˙˙˙˙˙˙˙â"""/€˙˙˙ţ˙|żßíţßű`~˙żţ˙˙˙˙˙ß˙˙ýőUUUUUUUUUUUU|∈ˆż˙˙˙˙ţsç?żĎíţĎóďďy÷˙żyó˙˙˙˙˙ß˙˙ýőUUUUUUUUUUUU|Ȁˆˆˆż˙˙˙˙ţżw÷_ż×íţĎóď÷{ű˙_ťý˙˙˙˙˙ß˙˙ůúŞŞŞŞŞŞŞŞŞŞŞŞźČ€"""/żř~˙ţßoűożŰíţ×ëď÷wű˙_ˇý˙˙CŮÇáßg˙ÁúŞŞŞŞŞŞŞŞŞŞŞŞź{œgď€â"""/ż÷˝ď˙ţďoűwżÝíţ×ëďďw˙ţďw˙˙˙=ŐťŢŢç˙ýőUUUUUUUUUUUU|BR”Ľ∈ˆ€ďŰ÷˙ţďoűwżÝíţŰŰŕw˙ţďw˙˙~Ď}žÝ˙˙ýőUUUUUUUUUUUU|BR”ĄȀˆˆˆżďŰ÷˙ţ÷oű{żŢíţŰŰď÷w˙ý÷ˇý˙˙~ßřŰ˙˙ýúŞŞŞŞŞŞŞŞŞŞŞŞźsœ—ÂȀ"""/żďŰ÷đţűoű}°ßmţÝťď÷wűüˇý˙˙~ßĆŐ˙˙ýúŞŞŞŞŞŞŞŞŞŞŞŞźB”•â"""/żďŰ÷˙ţýw÷~żßŽýÝťď÷{űűűťů˙˙~ßžÎ˙˙ýőUUUUUUUUUUUU|BR”Ľ∈ˆż÷˝ď˙ţţsç?ßÎyŢ{ď÷y÷űűšő˙˙=ß˝źßg˙ýőUUUUUUUUUUUU|zRd™âȀˆˆˆżř~˙ţ˙|żßď‡Ţ{o÷~÷ýž ˙˙CßĂÂ_§˙ýúŞŞŞŞŞŞŞŞŞŞŞŞźČ€"""/˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙úŞŞŞŞŞŞŞŞŞŞŞŞźâ"""/˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙őUUUUUUUUUUUU|∈ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙őUUUUUUUUUUUU|sž$ˆČ€ˆˆˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙üJPUȀ""",â""",˙}÷˙÷˙˙ţŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞâ""""""}˙î÷˙}÷˙˙÷˙˙ýUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUb"""""ˆý˙î÷ţ˙şďh~‡šÝUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUhˆˆˆˆˆ€ˆý˙ő÷ţ˙˙şďg˝ç{šŢŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞčˆˆˆˆˆ€"|űđ˙˙şďoŰöýśŢŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞâ""""""}˙ő÷ţ˙˙×_oŰöýÖ˝UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUb"""""ˆý˙î÷ţ˙×_oŰöýÖ˝UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUhˆˆˆˆˆ€ˆý˙î÷˙×_oŰöýď~ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞčˆˆˆˆˆ€"}˙ßw˙>˙ďżoÝç{ď~ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞâ""""""|ż°Á˙ďżoއď}UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUb"""""ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙ýUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUhˆˆˆˆˆ€ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙ţŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞčˆˆˆˆˆ€"˙˙˙˙˙˙˙˙˙˙˙˙˙ţŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞâ""""""˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙â"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕ€hˆˆˆˆˆ€"cá€ŕ 0@b""""""`"€"@P@b"""""ˆŕB‚"DŮÄF‘XpŕP hˆˆˆˆˆ€ˆŕD„DŠ ‘d‰" hˆˆˆˆˆ€"`„ˆDŠˆ‘@řŔ" b""""""`‡Ä"DŠH‘"@€ "ř b"""""ˆá‚"LŠI“"@‰" hˆˆˆˆˆ€ˆá€4¨á†@pŕ@hˆˆˆˆˆ€"`€@b""""""`€€b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"aŔ‚ŕă€b""""""`€@€"@€b"""""ˆŕ…‡,XpăŔ,8đņ‘68ąŕ‡"DŮÄF‘Xpŕ6Dqŕ‡ąe‡hˆˆˆˆˆ€ˆŕ†H‘2d‰2D@&I‘*DȀ€DŠ ‘d‰*Dˆ€H€ÉŚH™hˆˆˆˆˆ€"`„H @ů 0@ä‘*|ˆ€€DŠˆ‘@řŔπ*D`€O€‰¤Ob""""""`„H @ @$‘*@ˆ€€"DŠH‘"@€ *D€H"‰¤Hb"""""ˆŕ„H‘ @‰  DH$ “*DˆH€"LŠI“"@‰*LˆH€"‰2ŚHhˆˆˆˆˆ€ˆáÄG @pŕŔ 80ä*8ˆ`‡4¨á†@pŕ*4p`‡ˆŇĽ‡hˆˆˆˆˆ€"`€€b""""""`€b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"c€ b""""""b@ b"""""ˆâDOxáŔhˆˆˆˆˆ€ˆăÄD " hˆˆˆˆˆ€"b$D !€Ÿb""""""b$D @b"""""ˆâ$Ā$" hˆˆˆˆˆ€ˆăĂC!Ŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"cŕb""""""bb"""""ˆâ‡hˆˆˆˆˆ€ˆăÄH€hˆˆˆˆˆ€"bH€b""""""bH€b"""""ˆâH€hˆˆˆˆˆ€ˆâ‡hˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""`b"""""ˆŕhˆˆˆˆˆ€ˆŕhˆˆˆˆˆ€"`b""""""˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙â"""""ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙興ˆˆˆ€ˆˆˆż˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ˆ€"""?˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙""""?˙˙˙˙˙˙˙˙ć˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ü˙˙˙óÇ˙˙˙˙˙˙˙˙˙˙˙˙˙˙ű˙đ"ˆˆˆż˙˙˙˙˙˙˙Ţ˙˙ż˙˙˙˙˙˙˙˙ý˙˙óŸ˙˙üůď9˙˙˙˙˙˙˙˙˙˙˙˙˙÷ű˙đˆ€ˆˆˆż˙˙˙˙˙˙˙ß˙˙ż˙˙˙˙˙˙˙˙ý˙˙ďď˙˙ýýîţ˙˙˙˙˙˙˙˙˙˙˙˙˙÷ű˙đˆ€"""?t?‡˛Î??†Ů‡đěáoÚ1ńčxţ˙˙ôcżpăúąîqœgž""""?sŢ÷{Ş­Ţ÷ŢŐ{żďjŢoŮÎîç˝˙{ß÷ýű9Űţďď7îö­Ýď˙˙óżowůďq JR”"ˆˆˆżwíöýž{í÷ŢĎżßgżoŰŢßoÝ˙wďř=ű{Űţďƒßˇíö{í˙˙˙÷˝żo÷űöń JR„ˆ€ˆˆˆżwíţýžř ˙Ţ߇żüożoŰŢŔoÝ˙wď˙Ýű{ŰţďýߡďĆř˙˙÷˝żp÷űö1Îr\gˆ€"""?wíţýžűý˙ŢßűżăożoŰŢßďÝ˙wď˙íű{Űţďţߡî6ű˙ďá‡÷˝żwűöń RT""""?wíţýžűý˙Ţß{żßożo›ŢßďÝ˙wďďíó{ÝýîţߡÍöűýď˙˙÷˝žowűöń JR”"ˆˆˆżwî÷{žýî÷Ţß{żŢoŢo[ŢďoÝ˙{ß÷Ýë{Üůď}ď7­ćýíď˙˙÷˝˝owůďqéI’gˆˆ€ˆˆˆżwţ?Ţ߇Ÿá/ápŰŢđďÜ˙{ßďƒđ¸nţ˙˙÷˝Ăpóú°ˆ€"""?˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙˙˙˙˙˙˙˙˙đ""""?˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙Ţ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙˙˙˙˙˙˙˙˙đ"ˆˆˆż˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙á˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙˙˙˙˙˙˙˙˙ńÎx’ ˆ€ˆˆˆż˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ń)AT`ˆ€"""0ń)AX """"0ńÎqX "ˆˆˆ°ń*Cô ˆ€ˆˆˆ°ń)B2 ˆ€"""0ńÉz1p""""0đ"ˆˆˆ°đˆ€ˆˆˆ°đˆ€"""0ńîqœ""""0ń JR"ˆˆˆ°ń JRˆ€ˆˆˆ°ńÎr\ˆ€"""0ń RT""""0ń JR"ˆˆˆ° ńéI’ˆ€ˆˆˆ°Cç<€đˆ€"""0BH‘"€đ""""0‚H‘"ąaćđ"ˆˆˆ°ƒÇ<ɒ%™đĆK€ˆ€ˆˆˆ°‚ (‰&‘ń)j@ˆ€"""0‚‰$‰%ń z@""""0‚H‘"É$ˆ‘ń z@"ˆˆˆ°CäHŽ"ąÄGń Z@ˆ€ˆˆˆ°@ń)Z@ˆ€"""0 đĆK€""""0đ"ˆˆˆ°đˆ€ˆˆˆąóŕđˆ€"""0đŔ„`""""0"ń J"ˆˆˆ°#Áń j\ƒ¤Î1Ȁˆˆˆ°B đÉVHd¤)Jˆ€"""0@ đ)VH¤čqƒ""""0‚!ń)VH”Ľ(@C"ˆˆˆ°ÁđÇUˆcœŘ3ƒˆ€ˆˆˆ°đ€ˆ€"""0đ€""""0đ"ˆˆˆ°ńč’ˆ€ˆˆˆ°ńވ€"""0ń Ş""""0ńÍŞ"ˆˆˆ°ń~ˆ€ˆˆˆ°ńFˆ€"""0ńâGŔ""""0đ"ˆˆˆ°đˆ€ˆˆˆ°đˆ€"""0ń3’""""0ńJR"ˆˆˆ°ńB^ˆ€ˆˆˆ°ń3Œˆ€"""0ń """"0ńJ"ˆˆˆ°ńç2ˆ€ˆˆˆ°đˆ€"""0đ""""0đ"ˆˆˆ°ńîqœgžˆ€ˆˆˆ°ń JR”ˆ€"""0ń JR„""""0ńÎr\g"ˆˆˆ°ń RTˆ€ˆˆˆ°ń JR”ˆ€"""0ńéI’gˆ""""0đ"ˆˆˆ°đˆ€ˆˆˆ°đˆ€"""0ńč’ ř""""0ńŞ "ˆˆˆ°ń Ş ˆ€ˆˆˆ°ńÍŞ ˆ€"""0ń~ """"0ńF "ˆˆˆ°ńâGĚ ˆ€ˆˆˆ°đˆ€"""0đ""""0đ"ˆˆˆ°ńîqœgžˆ€ˆˆˆ°ń JR”ˆ€"""0ń JR„""""0ńÎr\g"ˆˆˆ°ń RTˆ€ˆˆˆ°ń JR”ˆ€"""0ńéI’gˆ""""0đ"ˆˆˆ°đˆ€ˆˆˆ°đˆ€"""0ńđ""""0đ@"ˆˆˆ°đ@ˆ€ˆˆˆ°đ@ˆ€"""0đ@""""0đ@"ˆˆˆ°đ@ˆ€ˆˆˆ°đˆ€"""0đ""""0đ"ˆˆˆ°đˆ€ˆˆˆ°đˆ€"""0đ""""?˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙"ˆˆˆż˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ˆ€ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ€""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Second Example: Define a function to return the tail of a list starting from its second to last element. (DEFINEQ (SecondFromLast (LAMBDA (List) (* * Return the tail of a list starting from its second to last element. Make sure List is in fact a list and is of length 2 or more.) (COND ((NOT (LISTP List)) (ERROR "SecondFromLast: Argument must be a list. It is --" List)) ((LESSP (LENGTH List) 2) (ERROR "SecondFromLast: List argument must be at least 2 items long. Its current length is --" (LENGTH List))) (T (NTH List (DIFFERENCE (LENGTH List) 2))))))) đűˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ"""/˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ţ"""""/˙˙˙˙˙˙˙˙˙˙˙˙˙˙ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŽ""ˆˆˆ€7öř?ďžď˙ţ˙˙˙ŐUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\ˆˆˆˆˆżűî˙çßďžď˙ţ˙˙˙ŐUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\ˆˆ"""/żýŢ˙ďďďž˙˙ţ˙˙˙ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŽ"""""/żýŢ˙ßď÷]íÂđ÷;ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŽ""ˆˆˆżţž˙ß˙÷]ě÷źďw;ŐUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\ˆˆˆˆˆ€~ß˙÷]íű~ßśŰŐUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\ˆˆ"""/żţž˙ß˙úëíű~ßş×ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŽ"""""/żýŢ˙ßďúëíű~ßş×ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŽ""ˆˆˆżýŢ˙ďďúëíű~ß˝ďŐUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\ˆˆˆˆˆżűî˙çßý÷íűźď}ďŐUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\ˆˆ"""/€7öř?ý÷íűÂđýďŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŽ"""""/˙˙˙˙˙˙˙˙˙˙˙˙˙˙ŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŞŽ""ˆˆˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙ŐUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\ˆˆˆˆˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙ŐUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\ˆˆ"""/˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ţ""""",""ˆˆˆŒ ˆˆˆˆˆŒ‰đ ˆˆ""",ˆ€""""", ˆ@""ˆˆˆŒ p ˆˆˆˆˆŒ ˆˆ""",""""",""ˆˆˆŒ@@ ˆˆˆˆˆŒ|pƒ€ đ„>ůđ ˆˆ""",ˆ„@ @„""""",ˆAGXi͐8đ@€""ˆˆˆŒp‘"d™ă$JD@ ńŕ@€ ˆˆˆˆˆŒ‰ń"D‰J0@‰@€ ˆˆ""",ˆH"D‰J"@@€""""", ˆAH‘"D™J"DH‰@€""ˆˆˆŒ pƒ‡DiŠŸ80‡Çpŕ ˆˆˆˆˆŒ€€ ˆˆ""",@@""""",""ˆˆˆŒ ˆˆˆˆˆŒ8Ÿ@p ˆˆ""",D@@"€""""",Dpáņ,8ŮÏ@păŔDŘâǀ"8đÀ<áÏ"qáĆÇ8°Đ""ˆˆˆŒ0‰&Iž2DŠ$D@™&DŠ""D@$@$D‚%H€DÉ0 ˆˆˆˆˆŒů$H DŠă@Á"DŠň""0@'ŔńăƒĺFD‰ ˆˆ""",D$H DŠ „@!"DŠ""@$ „‚AD‰""""",D‰$I DŠ$D„@ &LŠ"@&DH$@$D€ ’%H€D‰0€""ˆˆˆŒ8páÄF 8Šńăƒ|ŕŔ4¨â!€80À áăƒ>aĹG8ˆĐ€ ˆˆˆˆˆŒ ˆˆ""",ŕ""""",""ˆˆˆŒ ˆˆˆˆˆŒŔ@ ˆˆ""", @@@""""",xpÄKXđC‹ D@GȑD!€Ÿ ˆˆ""", H D@D‘D @""""",$ˆ$Č"DHDH“D" ""ˆˆˆŒpĂHD0Cˆ D!Ŕ ˆˆˆˆˆŒ ˆˆ""",""""",""ˆˆˆŒ ˆˆˆˆˆŒ ˆˆ""",0""""",P""ˆˆˆŒ ˆˆˆˆˆŒ ˆˆ""",""""",""ˆˆˆŒ| ˆˆˆˆˆŒ ˆˆ""",""""",""ˆˆˆŒ ˆˆˆˆˆŒ ˆˆ""",""""",""ˆˆˆŒ ˆˆˆˆˆŒ ˆˆ""",""""",""ˆˆˆŒ ˆˆˆˆˆŒ ˆˆ""",""""",""ˆˆˆŒ ˆˆˆˆˆŒ ˆˆ"""/˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ţ"""""/˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ţ""ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ˆˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ˆ"˙˙˙˙˙ý€˙˙˙˙˙˙˙ßű˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙÷˙˙˙˙ř˙ßŕ˘"~s˙˙˙˙˙ýż˙˙˙˙˙˙÷˙ßű˙ż˙˙˙˙˙˙˙˙ý˙˙˙˙ţ˙˙˙˙ß÷˙˙˙ß÷Ýŕ˘ˆýý˙˙˙˙˙ýż˙˙˙˙˙˙÷˙ß˙˙ż˙˙˙˙˙˙˙˙ý˙˙˙˙ţ˙˙˙˙ß÷˙˙˙ßďżýŕˆˆýýăđřz…żěáčÇđđă?ßű‡đěáoÚ1ńčxţŒwîCń˙Ï÷ĂÏďżŘăÜă8Ď|ˆ"~˙ÝďwšďyżęŢç;ďow?ßű{żďjŢoŮÎîç˝ţsˇíî˙=î˙˝ß÷w˝˝ß˙żÝ┼(˘"žßoŰöý€çżo{ßo÷˙ßűżßgżoŰŢßoÝţ÷ˇíţ˙~ß}ßöű}żß˙Ý┼˘ˆ˙ű€ßďŰöýżďżo{üp÷˙ßű‡żüożoŰŢŔoÝţ÷ˇî˙~ŔńßöńĂßü˙Ýăœä¸Îˆˆ˙ýżßďŰöýżďżo{ăw˙ßűűżăożoŰŢßďÝţ÷ˇďî˙~ß˙ßö˙ýßű˙Ý⤨(ˆ"}ýżßďŰöýżďżo{ßow˙ßű{żßożo›ŢßďÝţ÷ˇÍî˙~ß˙}ßö˙}˝ß÷˙Ý┼(˘"~űŢďwť÷yżďŢď{Ţow?ßű{żŢoŢo[ŢďoÝţ÷ˇ­î˙=ďyß÷{y˝ßď˙Ýăғ$Ϣˆ˙áđř{÷…żďáď{á0ó?Ŕ;‡Ÿá/ápŰŢđďÜţ÷¸nCđ˙„Ď÷‡„ĂĎŕ?Üŕˆˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ż˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ŕˆ"˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙Ţ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ŕ˘"˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙á˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ăœń$@˘ˆ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙âR‚¨ŔˆˆŕâR‚°@ˆ"`ăœâ°@˘"`âT‡č@˘ˆŕâR„d@ˆˆŕă’ôbŕˆ"`ŕ˘"`ŕ˘ˆŕŕˆˆŕăÜă8ˆ"`┤˘"`┤˘ˆŕăœä¸ˆˆŕ⤨ˆ"`┤˘"`@ ăғ$˘ˆŕ‡Ďxŕˆˆŕ„‘"Dŕˆ"a‘"DbÉ,ŕ˘"a"x“$J2጗˘ˆá "PL"âRԀˆˆá "HJ"âô€ˆ"a‘"D’I"âô€˘"`‡Č‘DbˆŽ"â´€˘ˆŕ€âR´€ˆˆŕ@ ጗ˆ"`ŕ˘"`ŕ˘ˆăă€ŕˆˆŕ$@á€/€ˆ"`DBâ@(€˘"`DBâ c8čqšƒÁ˘ˆŕƒŔᒔĽ.JU€ ˆˆŕ€@ŕ\„Ľ(BUƒ˜ˆ"aBâP”Ľ(BU„„Ą˘"a‚áŒc$čA•óxA˘ˆŕŕˆˆŕŕˆ"`ŕ˘"`ăŃ$˘ˆŕâTˆˆŕâTˆ"`ă›T˘"`â ü˘ˆŕ⌈ˆŕăď€ˆ"`ŕ˘"`ŕ˘ˆŕŕˆˆŕâg$ˆ"`┤˘"`â„ź˘ˆŕâgˆˆŕâ<ˆ"`â”$˘"`ăÎd$˘ˆŕŕˆˆŕŕˆ"`ŕ˘"`ăÜă8Ď|˘ˆŕ┼(ˆˆŕ┼ˆ"`ăœä¸Î˘"`⤨(˘ˆŕ┼(ˆˆŕăғ$Ďˆ"`ŕ˘"`ŕ˘ˆŕŕˆˆŕăŃ$đˆ"`âT$@˘"`âT$@˘ˆŕă›T$@ˆˆŕâ ü$@ˆ"`âŒ$@˘"`ăď˜@˘ˆŕŕˆˆŕŕˆ"`ŕ˘"`ăÜă8Ď|˘ˆŕ┼(ˆˆŕ┼ˆ"`ăœä¸Î˘"`⤨(˘ˆŕ┼(ˆˆŕăғ$Ďˆ"`ŕ˘"`ŕ˘ˆŕŕˆˆŕăŕˆ"`ŕ€˘"`ŕ€˘ˆŕŕ€ˆˆŕŕ€ˆ"`ŕ€˘"`ŕ€˘ˆŕŕˆˆŕŕˆ"`ŕ˘"`ŕ˘ˆŕŕˆˆŕŕˆ"˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˘"˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˘ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Type checking predicates The predicates necessary for checking the type of a given piece of data have already been discussed. LispLecture #4 (page 3), discusses the predicates LITATOM, NUMBERP, and LISTP that check if their argument is of type litatom, number, and list, respectively. LispLecture #25 (page 13) discusses the TYPE? statement that allows one to build predicates that check if their argument is a particular type of RECORD or a particular DATATYPE. The next section contains an overview of the types of data in Interlisp, including the predicates that check for each of the types. Overview of the Types of Data in Interlisp Below is a list of the types of data supported by Interlisp. In parentheses following each data type is the predicate that checks for that data type. Primitive data types (those provided as part of the core Interlisp system). Atoms (ATOM) Litatoms (LITATOM) Numbers (NUMBERP) Integers (FIXP) Floating Point Numbers (FLOATP) Lists (LISTP) [Prop Lists] [Assoc Lists] Strings (STRINGPs) Arrays (ARRAYPs) Compound data types (those built by combining primitive data types) RECORDs RECORDs defined by the Interlisp implementors SKETCHs (TYPE? SKETCH) GRAPHs (no type checking predicate!) ... User defined RECORDs (TYPE? RecordName) DATATYPEs DATATYPEs defined by the Interlisp implementors BITMAPs (BITMAPP) HARRAYs (HARRAYP) WINDOWs (WINDOWP) PROCESSes (PROCESSP) STREAMs (STREAMP) ... User defined DATATYPEs (TYPE? DataTypeName) Print Names Every data object in Interlisp has something called a print name (often called a pname). A data object's print name is the thing that gets printed when Lisp needs to communicate with the outside world › e.g., in the PRINT phase of the READ-EVAL-PRINT loop. Examples: Atoms: the print name is the name of the atom. E.g., FOOBAR. Lists: the print name starts with a "(", followed by the print names of all of the items in the list separated by spaces, followed by a ")". E.g., (1 (2 3) A). DATATYPES: the print name is the DatatypeName in "{ }" followed by some numbers. E.g., {WINDOW}#65,12345 and {PROCESS}#12,12399 Print names are NOT unique. For example: {WINDOW}#65,1234 is the print name for some window. But it is also the print name for an atom whose name (i.e., print name) is exactly {WINDOW}65,1234. For some data types, the Lisp object can be referred to by typing its print nameinto the Lisp Exec. For example, to refer to an atom, you just type its print name (i.e., its name) into the Lisp Exec. For other data types, the print name is just for printing; you can't type it back into the Lisp exec to refer to the object. For example, if you type in {WINDOW}#65,12345 into the Lisp Exec, the Lisp Exec will think you mean the atom by that name, not the window that has that pname. Arrays An array is a primitive data type that represents a fixed number (N) of other Interlisp objects stored in a one-dimensional vector. (NIL ((.05 13.0 NIL) (TEXT (16.0 . 256.0) ("An Array with 7 Elements") 1.0 (LEFT BASELINE) ( HELVETICA 12) ((16.0 253.0 186.0 13.0)) NIL)) ((.05 19.0 NIL) (TEXT (8.0 . 208.0) ("1:") 1.0 (CENTER BASELINE) (HELVETICA 18) ((1.0 204.0 15.0 19.0)) NIL)) ((.032 68.0 NIL) (TEXTBOX (24.0 200.0 136.0 32.0) ("(1 2 3 (3 4))") 1.0 (CENTER CENTER) (HELVETICA 10) ((61.0 210.0 63.0 12.0)) NIL 2)) ((.032 68.0 NIL) (TEXTBOX (24.0 168.0 136.0 32.0) ("444") 1.0 (CENTER CENTER) (HELVETICA 10) ((82.0 178.0 21.0 12.0)) NIL 2)) ((.05 19.0 NIL) (TEXT (8.0 . 176.0) ("2:") 1.0 (CENTER BASELINE) (HELVETICA 18) ((1.0 172.0 15.0 19.0)) NIL)) ((.032 68.0 NIL) (TEXTBOX (24.0 136.0 136.0 32.0) ("FooBar") 1.0 (CENTER CENTER) (HELVETICA 10) ((70.0 146.0 45.0 12.0)) NIL 2)) ((.05 19.0 NIL) (TEXT (8.0 . 144.0) ("3:") 1.0 (CENTER BASELINE) ( HELVETICA 18) ((1.0 140.0 15.0 19.0)) NIL)) ((.032 68.0 NIL) (TEXTBOX (24.0 104.0 136.0 32.0) ("{WINDOW}#1,2234") 1.0 (CENTER CENTER) (HELVETICA 10) ((30.0 114.0 124.0 12.0)) NIL 2)) ((.05 19.0 NIL) (TEXT (8.0 . 112.0) ("4:") 1.0 (CENTER BASELINE) (HELVETICA 18) ((1.0 108.0 15.0 19.0)) NIL)) ((.032 68.0 NIL) (TEXTBOX (24.0 72.0 136.0 32.0) ( "(List of Elements)") 1.0 (CENTER CENTER) (HELVETICA 10) ((40.0 82.0 104.0 12.0)) NIL 2)) (( .05 19.0 NIL) (TEXT (8.0 . 80.0) ("5:") 1.0 (CENTER BASELINE) (HELVETICA 18) ((1.0 76.0 15.0 19.0)) NIL)) ((.032 68.0 NIL) (TEXTBOX (24.0 40.0 136.0 32.0) ("1.2345") 1.0 (CENTER CENTER) (HELVETICA 10) ((73.0 50.0 39.0 12.0)) NIL 2)) ((.05 19.0 NIL) (TEXT (8.0 . 48.0) ( "6:") 1.0 (CENTER BASELINE) (HELVETICA 18) ((1.0 44.0 15.0 19.0)) NIL)) ((.032 68.0 NIL) ( TEXTBOX (24.0 8.0 136.0 32.0) ("{PROCESS}#1,2234") 1.0 (CENTER CENTER) (HELVETICA 10) ((27.0 18.0 131.0 12.0)) NIL 2)) ((.05 19.0 NIL) (TEXT (8.0 . 16.0) ("7:") 1.0 (CENTER BASELINE) (HELVETICA 18) ((1.0 12.0 15.0 19.0)) NIL))) (0 0 162.0 266.0) 1.0 8.0 Think of an array as a set of mailboxes arranged in one column and N rows. In each mailbox is some arbitrary Interlisp object (an atom, a list, a window, etc.) You can get at any object stored in the array of mailboxes only by specifying the row number of the mailbox it is stored in. Alternatively, an array is like a RECORD with N fields, but the fields can be accessed by number only and not by name. An array is also like a list, but it has a fixed length: you can't add or remove elements from an array. Moreover, you can't deal with parts of the array as a single entity as you can a list (e.g., there is no operation like CDR for arrays). For certain applications, arrays are much more efficient than lists. In general, however, any program that uses arrays can be rewritten using lists › with possible loss of efficiency and elegance. Array manipulation functions Interlisp has a number of functions that allow you to manipulate arrays, i.e., to create arrays, to access the objects stored in an array, etc. Creating arrays (ARRAY Size) œ Creates an array of size Size (i.e., with Size entries). Returns (a pointer to) the array. The array is initialized to have every element contain NIL. Example: 1_(SETQ MyArray (ARRAY 10)) {ARRAY}#65,51054 2_MyArray {ARRAY}#65,51054 Array predicate (ARRAYP Arg) œ Returns Arg if Arg is an array, NIL otherwise. Examples: 3_(ARRAYP MyArray) {ARRAY}#65,51054 4_(ARRAYP 10) NIL 5_ (ARRAYP (LIST 1 2 3 4 5)) NIL 6_ (ARRAYP 'ARRAY) NIL Accessing the entries of an array (SETA Array N Value) œ Sets the Nth element of Array to have the value Value (i.e., puts the Lisp object specified by Value into the Nth element of Array). Examples: 7_(SETA MyArray 1 (LIST 1 2 3)) (1 2 3) 8_(SETA MyArray 2 (PLUS 2 3)) 5 9_ (SETA MyArray 12 15) ILLEGAL ARG 12 10_ (SETA MyArray 3 15) 15 (ELT Array N) œ Returns the Lisp object stored in the Nth element of Array. Examples: 11_(ELT MyArray 1) (1 2 3) 12_(ELT MyArray 2) 5 13_ (ELT MyArray 12) ILLEGAL ARG 12 14_ (ELT MyArray 5) NIL Finding out the size of an array (ARRAYSIZE Array) œ Returns the size of array Array. Example: 15_(ARRAYSIZE MyArray) 10 16_ (ARRAYSIZE (ARRAY 50)) 50 Using arrays Problem: Imagine you work for a company that has 20 products (numbered 1 thru 20). Each product has a "list price" and an "our price". 1. Write a function that takes a product number and returns the "list price". 2. Write a function that takes a product number and returns the "our price". 3. Write a function that replaces the price entry field with the atom OutOfStock for a given product number. Solution: Store the data in an array of size 20, where each entry is a RECORD called Prices with 2 fields named ListPrice and OurPrice. (SETQ PriceArray (ARRAY 20)) (SETA PriceArray 1 (CREATE Prices ListPrice _ 1.00 OurPrice 1.25)) ... {Fill in rest of proce array with values} (DEFINEQ (LC.ListPrice (LAMBDA (ProductNumber) (fetch (Prices ListPrice) of (ELT PriceArray ProductNumber))) (LC.OurPrice (LAMBDA (ProductNumber) (fetch (Prices OurPrice) of (ELT PriceArray ProductNumber))) (LC.MarkOutOfStock (LAMBDA (ProductNumber) (SETA PriceArray ProductNumber 'OutOfStock)))) The advantage of using an array in this case is that you need to get to and CHANGE any element of the data structure at any time. This is easy with arrays using ELT and SETA. It is harder with lists. First, (CAR (NTH List N)) takes longer than (ELT Array N). Second, there is no easy way to do SETA with list structures. (Though we will learn how to do so not easily later!!!). Strings Strings are a primitive data type in Interlisp used for representing sequences of characters. (As opposed to atoms which are used as symbols for arbitrary objects.) A string is an arbitrary sequence of characters, including spaces and tabs. The print name of a string encloses the characters in the string in double quotes. Examples: "B" "abc" "Frank G. Halasz" "This is a very long string. It consists of several sentences. The sentences are separated by spaces." Strings can be from 0 to any number of characters in length. The string "" is the empty string having 0 characters. Strings can contain any characters except the double quote character and %. To include these characters they must be preceded by the % escape as in atom names. Example: "String with single %% percent sign" String manipulation functions Interlisp has a number of functions that allow you to manipulate strings, i.e., to create strings, to concatenate strings, to decompose strings, to search through strings, etc. String predicate (STRINGP Arg) œ Returns Arg if Arg is a string, NIL otherwise. Examples: 1_(STRINGP "ABC") "ABC" 2_(STRINGP 'ABCDEF) NIL 3_(STRINGP (LIST 1 2 3 4)) NIL 8_(STRINGP (TEDIT)) NIL Creating strings (MKSTRING Arg) œ If Arg is already a string, returns Arg. Otherwise, makes and returns a string containing the print name of Arg. Examples: 5_(MKSTRING "ABC") "ABC" 6_(MKSTRING 'ABCDEF) "ABCDEF" 7_(MKSTRING (LIST 1 2 3 4)) "(1 2 3 4)" 8_(MKSTRING (TEDIT)) "{PROCESS}#61,130000" (ALLOCSTRING N Character) œ Returns a string N characters long where each character is Character. Character can be a single character string/atom or a character code (see LispCourse #10, page 5) Examples: 9_(ALLOCSTRING 5 "A") "AAAAA" 10_(ALLOCSTRING 15 'B) "BBBBBBBBBBBBBBB" 11_(ALLOCSTRING (PLUS 3 4) 63) "???????" 12_(ALLOCSTRING 7 (CHARCODE ?)) "???????" Comparing strings (STREQUAL Str1 Str2) œ Returns T is Str1 and Str2 are both strings and contain the same sequence of characters. Examples: 13_(STREQUAL "ABCDEF "ABCDEF") T 14_(STREQUAL (ALLOCSTRING 5 'A) "AAAAA") T 15_(STREQUAL 'A "A") NIL 16_(STREQUAL (MKSTRING 'AAA)(ALLOCSTRING 3 "A")) T Concatenating strings (CONCAT Str1 Str2 ...) œ Returns a new string that consists of the concatenation of the characters in Str1, Str2, Str3 .... If any StrI is not a string, the MKSTRING of that STRI is used instead of StrI. Examples: 17_(CONCAT "ABCDEF "GHIJKL") "ABCDEFGHIJKL" 18_(CONCAT (ALLOCSTRING 5 'A) "FOO BAR") "AAAAAFOO BAR" 19_(CONCAT 1234 " " 5678 " " (LIST 9 0)) "1234 5678 (9 0)" 20_(CONCAT "This is the kind of value that TEdit returns -- " (TEDIT)) "This is the kind of value that TEdit returns -- {PROCESS}#61,130000" Decomposing strings (SUBSTRING Str Start End) œ Returns a new string that consists of the characters of Str starting at character number Start and ending at character number End. If End is NIL, the last character of Str is used. If Start or End are negative, they are interpreted as being positions from the end of Str. Examples: 21_(SUBSTRING "ABCDEF 2 4) "BCD" 22_(SUBSTRING "FOO BAR" 4) " BAR" 23_(SUBSTRING "FOO BAR" ›3) "BAR" 24_(SUBSTRING "FOO BAR" 2 -2) "OO BA" Searching strings (STRPOS Pattern String Start SkipChar) œ Searches through string String looking for any sequences of characters that matches the characters in string Pattern. If a match is found, STRPOS returns the number of the character in String where the match starts. If no match is found, STRPOS returns NIL. If Start is specified, the search begins at character number Start in String. If SkipChar is specified, any instance of SkipChar in the Pattern string will match any character in String. (SkipChar is the wildcard character). If Pattern and/or String are not strings, their MKSTRINGs will be used instead. Examples: 25_(STRPOS "Q" "ABCDEF") NIL 26_(STRPOS "D" "ABCDEF") 4 27_(STRPOS "C*E" "ABCDEF" NIL "*") 3 28_(STRPOS "O" "FOO BAR" 4) NIL Using Strings Given a list of strings of the format: "Name: Last,First". Write a function to extract all names with "sz" in them. The function should return a list of strings with the format "First Last". (DEFINEQ (LC.szP (LAMBDA (String) (* * Does String have an sz in it?) (OR (STRPOS "sz" String) (STRPOS "Sz" String) (STRPOS "sZ" String) (STRPOS "SZ" String)))) (LC.GetLastName (LAMBDA (String) (* * Extract the last name from the string) (SUBSTRING String (PLUS 1 (STRPOS " " String)) (DIFFERENCE (STRPOS "," String) 1)))) (LC.GetFirstName (LAMBDA (String) (* * Extract the first name from the string) (SUBSTRING String (PLUS 1 (STRPOS "," String))))) (LC.FindSzNames (LAMBDA (List) (* * Extract all names with sz in the last name) (FOR Entry in List WHEN (LC.szP Entry) COLLECT (CONCAT (LC.GetFirstName Entry) " " (LC.GetLastName Entry)))))) 6_(SETQ TestList (QUOTE ("Name: Halasz,Frank" "Name: Smith, Sam" "Name: Beals, Szmatha" "Name: Schatz,Sheila"))) ("Name: Halasz,Frank" "Name: Smith, Sam" "Name: Beals, Szmatha" "Name: Schatz,Sheila") 7_(LC.szP (CAR TestList)) 11 8_(LC.GetFirstName (CAR TestList)) "Frank" 9_(LC.GetLastName (CAR TestList)) "Halasz" 10_(LC.FindSzNames TestList) ("Frank Halasz" " Szmatha Beals") References In general, primitive data types are covered in Chapter 2 of the IRM. Arrays are covered in Section 2.7. Strings are covered in Section 2.6. (LIST ((PAGE NIL NIL (0 0 17 22) ((HEADING NIL (HEADINGTYPE YYY) (540 756 72 36) NIL) (TEXT NIL NIL (72 72 468 648) NIL))) (PAGE NIL NIL (0 0 17 22) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 SIZE 12 FAMILY TIMESROMAN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF SLOPE REGULAR WEIGHT MEDIUM)) (468 756 72 36) NIL) (HEADING NIL (HEADINGTYPE XXX) (72 756 72 36) NIL) (TEXT NIL NIL (72 72 468 648) NIL))) (PAGE NIL NIL (0 0 17 22) ((FOLIO NIL (PARALOOKS (QUAD RIGHT) CHARLOOKS (SUPERSCRIPT 0 SIZE 12 FAMILY TIMESROMAN OVERLINE OFF STRIKEOUT OFF UNDERLINE OFF SLOPE REGULAR WEIGHT MEDIUM)) (468 756 72 36) NIL) (HEADING NIL (HEADINGTYPE XXX) (72 756 72 36) NIL) (TEXT NIL NIL (72 72 468 648) NIL)))))-HHHH$$ llllŘŘ´´ll HHHH $$ $$llllll  üü$$´´ŘŘŘŘ llll HH HH$$ ll$$´´ ´´ll HH$$$$ˆ PAGEHEADINGXXXH PAGEHEADINGYYY TIMESROMAN  TIMESROMAN  TIMESROMAN  TIMESROMAN TIMESROMAN -,0+0*ÇČJ8"%* I$  $Wb U×  " (@&ž 9Ę BMOBJ.GETFN2 TIMESROMAN `$i’Ę2{…Ł'ĹŸ^@R!R  Z[#