home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Python 1.1 / Doc / libarray.tex < prev    next >
LaTeX Document  |  1994-08-08  |  3.8 KB  |  [TEXT/R*ch]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: LaTeX Document (document/latex).

You can browse this item here: libarray.tex

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert LaTeX Document (document/latex) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file LaTeX document text default
99% file LaTeX document, ASCII text, with CR line terminators default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/281 LaTeX (Subdocument) default
100% detectItEasy Format: plain text[CR] default (weak)


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[R*ch]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 42 75 69 6c 74 2d 69 |\section|{Built-i|
|00000010| 6e 20 6d 6f 64 75 6c 65 | 20 5c 73 65 63 74 63 6f |n module| \sectco|
|00000020| 64 65 7b 61 72 72 61 79 | 7d 7d 0d 5c 62 69 6d 6f |de{array|}}.\bimo|
|00000030| 64 69 6e 64 65 78 7b 61 | 72 72 61 79 7d 0d 5c 69 |dindex{a|rray}.\i|
|00000040| 6e 64 65 78 7b 61 72 72 | 61 79 73 7d 0d 0d 54 68 |ndex{arr|ays}..Th|
|00000050| 69 73 20 6d 6f 64 75 6c | 65 20 64 65 66 69 6e 65 |is modul|e define|
|00000060| 73 20 61 20 6e 65 77 20 | 6f 62 6a 65 63 74 20 74 |s a new |object t|
|00000070| 79 70 65 20 77 68 69 63 | 68 20 63 61 6e 20 65 66 |ype whic|h can ef|
|00000080| 66 69 63 69 65 6e 74 6c | 79 20 72 65 70 72 65 73 |ficientl|y repres|
|00000090| 65 6e 74 0d 61 6e 20 61 | 72 72 61 79 20 6f 66 20 |ent.an a|rray of |
|000000a0| 62 61 73 69 63 20 76 61 | 6c 75 65 73 3a 20 63 68 |basic va|lues: ch|
|000000b0| 61 72 61 63 74 65 72 73 | 2c 20 69 6e 74 65 67 65 |aracters|, intege|
|000000c0| 72 73 2c 20 66 6c 6f 61 | 74 69 6e 67 20 70 6f 69 |rs, floa|ting poi|
|000000d0| 6e 74 0d 6e 75 6d 62 65 | 72 73 2e 20 20 41 72 72 |nt.numbe|rs. Arr|
|000000e0| 61 79 73 20 61 72 65 20 | 73 65 71 75 65 6e 63 65 |ays are |sequence|
|000000f0| 20 74 79 70 65 73 20 61 | 6e 64 20 62 65 68 61 76 | types a|nd behav|
|00000100| 65 20 76 65 72 79 20 6d | 75 63 68 20 6c 69 6b 65 |e very m|uch like|
|00000110| 20 6c 69 73 74 73 2c 0d | 65 78 63 65 70 74 20 74 | lists,.|except t|
|00000120| 68 61 74 20 74 68 65 20 | 74 79 70 65 20 6f 66 20 |hat the |type of |
|00000130| 6f 62 6a 65 63 74 73 20 | 73 74 6f 72 65 64 20 69 |objects |stored i|
|00000140| 6e 20 74 68 65 6d 20 69 | 73 20 63 6f 6e 73 74 72 |n them i|s constr|
|00000150| 61 69 6e 65 64 2e 20 20 | 54 68 65 0d 74 79 70 65 |ained. |The.type|
|00000160| 20 69 73 20 73 70 65 63 | 69 66 69 65 64 20 61 74 | is spec|ified at|
|00000170| 20 6f 62 6a 65 63 74 20 | 63 72 65 61 74 69 6f 6e | object |creation|
|00000180| 20 74 69 6d 65 20 62 79 | 20 75 73 69 6e 67 20 61 | time by| using a|
|00000190| 20 5c 64 66 6e 7b 74 79 | 70 65 20 63 6f 64 65 7d | \dfn{ty|pe code}|
|000001a0| 2c 0d 77 68 69 63 68 20 | 69 73 20 61 20 73 69 6e |,.which |is a sin|
|000001b0| 67 6c 65 20 63 68 61 72 | 61 63 74 65 72 2e 20 20 |gle char|acter. |
|000001c0| 54 68 65 20 66 6f 6c 6c | 6f 77 69 6e 67 20 74 79 |The foll|owing ty|
|000001d0| 70 65 20 63 6f 64 65 73 | 20 61 72 65 20 64 65 66 |pe codes| are def|
|000001e0| 69 6e 65 64 3a 0d 0d 5c | 62 65 67 69 6e 7b 74 61 |ined:..\|begin{ta|
|000001f0| 62 6c 65 69 69 69 7d 7b | 7c 63 7c 63 7c 63 7c 7d |bleiii}{||c|c|c|}|
|00000200| 7b 63 6f 64 65 7d 7b 54 | 79 70 65 63 6f 64 65 7d |{code}{T|ypecode}|
|00000210| 7b 54 79 70 65 7d 7b 4d | 69 6e 69 6d 61 6c 20 73 |{Type}{M|inimal s|
|00000220| 69 7a 65 20 69 6e 20 62 | 79 74 65 73 7d 0d 5c 6c |ize in b|ytes}.\l|
|00000230| 69 6e 65 69 69 69 7b 27 | 63 27 7d 7b 63 68 61 72 |ineiii{'|c'}{char|
|00000240| 61 63 74 65 72 7d 7b 31 | 7d 0d 5c 6c 69 6e 65 69 |acter}{1|}.\linei|
|00000250| 69 69 7b 27 62 27 7d 7b | 73 69 67 6e 65 64 20 69 |ii{'b'}{|signed i|
|00000260| 6e 74 65 67 65 72 7d 7b | 31 7d 0d 5c 6c 69 6e 65 |nteger}{|1}.\line|
|00000270| 69 69 69 7b 27 68 27 7d | 7b 73 69 67 6e 65 64 20 |iii{'h'}|{signed |
|00000280| 69 6e 74 65 67 65 72 7d | 7b 32 7d 0d 5c 6c 69 6e |integer}|{2}.\lin|
|00000290| 65 69 69 69 7b 27 69 27 | 7d 7b 73 69 67 6e 65 64 |eiii{'i'|}{signed|
|000002a0| 20 69 6e 74 65 67 65 72 | 7d 7b 32 7d 0d 5c 6c 69 | integer|}{2}.\li|
|000002b0| 6e 65 69 69 69 7b 27 6c | 27 7d 7b 73 69 67 6e 65 |neiii{'l|'}{signe|
|000002c0| 64 20 69 6e 74 65 67 65 | 72 7d 7b 34 7d 0d 5c 6c |d intege|r}{4}.\l|
|000002d0| 69 6e 65 69 69 69 7b 27 | 66 27 7d 7b 66 6c 6f 61 |ineiii{'|f'}{floa|
|000002e0| 74 69 6e 67 20 70 6f 69 | 6e 74 7d 7b 34 7d 0d 5c |ting poi|nt}{4}.\|
|000002f0| 6c 69 6e 65 69 69 69 7b | 27 64 27 7d 7b 66 6c 6f |lineiii{|'d'}{flo|
|00000300| 61 74 69 6e 67 20 70 6f | 69 6e 74 7d 7b 38 7d 0d |ating po|int}{8}.|
|00000310| 5c 65 6e 64 7b 74 61 62 | 6c 65 69 69 69 7d 0d 0d |\end{tab|leiii}..|
|00000320| 54 68 65 20 61 63 74 75 | 61 6c 20 72 65 70 72 65 |The actu|al repre|
|00000330| 73 65 6e 74 61 74 69 6f | 6e 20 6f 66 20 76 61 6c |sentatio|n of val|
|00000340| 75 65 73 20 69 73 20 64 | 65 74 65 72 6d 69 6e 65 |ues is d|etermine|
|00000350| 64 20 62 79 20 74 68 65 | 20 6d 61 63 68 69 6e 65 |d by the| machine|
|00000360| 0d 61 72 63 68 69 74 65 | 63 74 75 72 65 20 28 73 |.archite|cture (s|
|00000370| 74 72 69 63 74 6c 79 20 | 73 70 65 61 6b 69 6e 67 |trictly |speaking|
|00000380| 2c 20 62 79 20 74 68 65 | 20 43 20 69 6d 70 6c 65 |, by the| C imple|
|00000390| 6d 65 6e 74 61 74 69 6f | 6e 29 2e 20 20 54 68 65 |mentatio|n). The|
|000003a0| 20 61 63 74 75 61 6c 0d | 73 69 7a 65 20 63 61 6e | actual.|size can|
|000003b0| 20 62 65 20 61 63 63 65 | 73 73 65 64 20 74 68 72 | be acce|ssed thr|
|000003c0| 6f 75 67 68 20 74 68 65 | 20 5c 76 61 72 7b 74 79 |ough the| \var{ty|
|000003d0| 70 65 63 6f 64 65 7d 20 | 61 74 74 72 69 62 75 74 |pecode} |attribut|
|000003e0| 65 2e 0d 0d 54 68 65 20 | 6d 6f 64 75 6c 65 20 64 |e...The |module d|
|000003f0| 65 66 69 6e 65 73 20 74 | 68 65 20 66 6f 6c 6c 6f |efines t|he follo|
|00000400| 77 69 6e 67 20 66 75 6e | 63 74 69 6f 6e 3a 0d 0d |wing fun|ction:..|
|00000410| 5c 72 65 6e 65 77 63 6f | 6d 6d 61 6e 64 7b 5c 69 |\renewco|mmand{\i|
|00000420| 6e 64 65 78 73 75 62 69 | 74 65 6d 7d 7b 28 69 6e |ndexsubi|tem}{(in|
|00000430| 20 6d 6f 64 75 6c 65 20 | 61 72 72 61 79 29 7d 0d | module |array)}.|
|00000440| 0d 5c 62 65 67 69 6e 7b | 66 75 6e 63 64 65 73 63 |.\begin{|funcdesc|
|00000450| 7d 7b 61 72 72 61 79 7d | 7b 74 79 70 65 63 6f 64 |}{array}|{typecod|
|00000460| 65 5c 6f 70 74 69 6f 6e | 61 6c 7b 5c 2c 20 69 6e |e\option|al{\, in|
|00000470| 69 74 69 61 6c 69 7a 65 | 72 7d 7d 0d 52 65 74 75 |itialize|r}}.Retu|
|00000480| 72 6e 20 61 20 6e 65 77 | 20 61 72 72 61 79 20 77 |rn a new| array w|
|00000490| 68 6f 73 65 20 69 74 65 | 6d 73 20 61 72 65 20 72 |hose ite|ms are r|
|000004a0| 65 73 74 72 69 63 74 65 | 64 20 62 79 20 5c 76 61 |estricte|d by \va|
|000004b0| 72 7b 74 79 70 65 63 6f | 64 65 7d 2c 20 61 6e 64 |r{typeco|de}, and|
|000004c0| 0d 69 6e 69 74 69 61 6c | 69 7a 65 64 20 66 72 6f |.initial|ized fro|
|000004d0| 6d 20 74 68 65 20 6f 70 | 74 69 6f 6e 61 6c 20 5c |m the op|tional \|
|000004e0| 76 61 72 7b 69 6e 69 74 | 69 61 6c 69 7a 65 72 7d |var{init|ializer}|
|000004f0| 20 76 61 6c 75 65 2c 20 | 77 68 69 63 68 20 6d 75 | value, |which mu|
|00000500| 73 74 20 62 65 20 61 0d | 6c 69 73 74 20 6f 72 20 |st be a.|list or |
|00000510| 61 20 73 74 72 69 6e 67 | 2e 20 20 54 68 65 20 6c |a string|. The l|
|00000520| 69 73 74 20 6f 72 20 73 | 74 72 69 6e 67 20 69 73 |ist or s|tring is|
|00000530| 20 70 61 73 73 65 64 20 | 74 6f 20 74 68 65 20 6e | passed |to the n|
|00000540| 65 77 20 61 72 72 61 79 | 27 73 0d 5c 63 6f 64 65 |ew array|'s.\code|
|00000550| 7b 66 72 6f 6d 6c 69 73 | 74 28 29 7d 20 6f 72 20 |{fromlis|t()} or |
|00000560| 5c 63 6f 64 65 7b 66 72 | 6f 6d 73 74 72 69 6e 67 |\code{fr|omstring|
|00000570| 28 29 7d 20 6d 65 74 68 | 6f 64 20 28 73 65 65 20 |()} meth|od (see |
|00000580| 62 65 6c 6f 77 29 20 74 | 6f 20 61 64 64 0d 69 6e |below) t|o add.in|
|00000590| 69 74 69 61 6c 20 69 74 | 65 6d 73 20 74 6f 20 74 |itial it|ems to t|
|000005a0| 68 65 20 61 72 72 61 79 | 2e 0d 5c 65 6e 64 7b 66 |he array|..\end{f|
|000005b0| 75 6e 63 64 65 73 63 7d | 0d 0d 41 72 72 61 79 20 |uncdesc}|..Array |
|000005c0| 6f 62 6a 65 63 74 73 20 | 73 75 70 70 6f 72 74 20 |objects |support |
|000005d0| 74 68 65 20 66 6f 6c 6c | 6f 77 69 6e 67 20 64 61 |the foll|owing da|
|000005e0| 74 61 20 69 74 65 6d 73 | 20 61 6e 64 20 6d 65 74 |ta items| and met|
|000005f0| 68 6f 64 73 3a 0d 0d 5c | 62 65 67 69 6e 7b 64 61 |hods:..\|begin{da|
|00000600| 74 61 64 65 73 63 7d 7b | 74 79 70 65 63 6f 64 65 |tadesc}{|typecode|
|00000610| 7d 0d 54 68 65 20 74 79 | 70 65 63 6f 64 65 20 63 |}.The ty|pecode c|
|00000620| 68 61 72 61 63 74 65 72 | 20 75 73 65 64 20 74 6f |haracter| used to|
|00000630| 20 63 72 65 61 74 65 20 | 74 68 65 20 61 72 72 61 | create |the arra|
|00000640| 79 2e 0d 5c 65 6e 64 7b | 64 61 74 61 64 65 73 63 |y..\end{|datadesc|
|00000650| 7d 0d 0d 5c 62 65 67 69 | 6e 7b 64 61 74 61 64 65 |}..\begi|n{datade|
|00000660| 73 63 7d 7b 69 74 65 6d | 73 69 7a 65 7d 0d 54 68 |sc}{item|size}.Th|
|00000670| 65 20 6c 65 6e 67 74 68 | 20 69 6e 20 62 79 74 65 |e length| in byte|
|00000680| 73 20 6f 66 20 6f 6e 65 | 20 61 72 72 61 79 20 69 |s of one| array i|
|00000690| 74 65 6d 20 69 6e 20 74 | 68 65 20 69 6e 74 65 72 |tem in t|he inter|
|000006a0| 6e 61 6c 20 72 65 70 72 | 65 73 65 6e 74 61 74 69 |nal repr|esentati|
|000006b0| 6f 6e 2e 0d 5c 65 6e 64 | 7b 64 61 74 61 64 65 73 |on..\end|{datades|
|000006c0| 63 7d 0d 0d 5c 62 65 67 | 69 6e 7b 66 75 6e 63 64 |c}..\beg|in{funcd|
|000006d0| 65 73 63 7d 7b 61 70 70 | 65 6e 64 7d 7b 78 7d 0d |esc}{app|end}{x}.|
|000006e0| 41 70 70 65 6e 64 20 61 | 20 6e 65 77 20 69 74 65 |Append a| new ite|
|000006f0| 6d 20 77 69 74 68 20 76 | 61 6c 75 65 20 5c 76 61 |m with v|alue \va|
|00000700| 72 7b 78 7d 20 74 6f 20 | 74 68 65 20 65 6e 64 20 |r{x} to |the end |
|00000710| 6f 66 20 74 68 65 20 61 | 72 72 61 79 2e 0d 5c 65 |of the a|rray..\e|
|00000720| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0d 0d 5c 62 |nd{funcd|esc}..\b|
|00000730| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 62 |egin{fun|cdesc}{b|
|00000740| 79 74 65 73 77 61 70 7d | 7b 78 7d 0d 60 60 42 79 |yteswap}|{x}.``By|
|00000750| 74 65 73 77 61 70 27 27 | 20 61 6c 6c 20 69 74 65 |teswap''| all ite|
|00000760| 6d 73 20 6f 66 20 74 68 | 65 20 61 72 72 61 79 2e |ms of th|e array.|
|00000770| 20 20 54 68 69 73 20 69 | 73 20 6f 6e 6c 79 20 73 | This i|s only s|
|00000780| 75 70 70 6f 72 74 65 64 | 20 66 6f 72 0d 69 6e 74 |upported| for.int|
|00000790| 65 67 65 72 20 76 61 6c | 75 65 73 2e 20 20 49 74 |eger val|ues. It|
|000007a0| 20 69 73 20 75 73 65 66 | 75 6c 20 77 68 65 6e 20 | is usef|ul when |
|000007b0| 72 65 61 64 69 6e 67 20 | 64 61 74 61 20 66 72 6f |reading |data fro|
|000007c0| 6d 20 61 20 66 69 6c 65 | 20 77 72 69 74 74 65 6e |m a file| written|
|000007d0| 0d 6f 6e 20 61 20 6d 61 | 63 68 69 6e 65 20 77 69 |.on a ma|chine wi|
|000007e0| 74 68 20 61 20 64 69 66 | 66 65 72 65 6e 74 20 62 |th a dif|ferent b|
|000007f0| 79 74 65 20 6f 72 64 65 | 72 2e 0d 5c 65 6e 64 7b |yte orde|r..\end{|
|00000800| 66 75 6e 63 64 65 73 63 | 7d 0d 0d 5c 62 65 67 69 |funcdesc|}..\begi|
|00000810| 6e 7b 66 75 6e 63 64 65 | 73 63 7d 7b 66 72 6f 6d |n{funcde|sc}{from|
|00000820| 66 69 6c 65 7d 7b 66 5c | 2c 20 6e 7d 0d 52 65 61 |file}{f\|, n}.Rea|
|00000830| 64 20 5c 76 61 72 7b 6e | 7d 20 69 74 65 6d 73 20 |d \var{n|} items |
|00000840| 28 61 73 20 6d 61 63 68 | 69 6e 65 20 76 61 6c 75 |(as mach|ine valu|
|00000850| 65 73 29 20 66 72 6f 6d | 20 74 68 65 20 66 69 6c |es) from| the fil|
|00000860| 65 20 6f 62 6a 65 63 74 | 20 5c 76 61 72 7b 66 7d |e object| \var{f}|
|00000870| 0d 61 6e 64 20 61 70 70 | 65 6e 64 20 74 68 65 6d |.and app|end them|
|00000880| 20 74 6f 20 74 68 65 20 | 65 6e 64 20 6f 66 20 74 | to the |end of t|
|00000890| 68 65 20 61 72 72 61 79 | 2e 20 20 49 66 20 6c 65 |he array|. If le|
|000008a0| 73 73 20 74 68 61 6e 20 | 5c 76 61 72 7b 6e 7d 20 |ss than |\var{n} |
|000008b0| 69 74 65 6d 73 0d 61 72 | 65 20 61 76 61 69 6c 61 |items.ar|e availa|
|000008c0| 62 6c 65 2c 20 5c 63 6f | 64 65 7b 45 4f 46 45 72 |ble, \co|de{EOFEr|
|000008d0| 72 6f 72 7d 20 69 73 20 | 72 61 69 73 65 64 2c 20 |ror} is |raised, |
|000008e0| 62 75 74 20 74 68 65 20 | 69 74 65 6d 73 20 74 68 |but the |items th|
|000008f0| 61 74 20 77 65 72 65 0d | 61 76 61 69 6c 61 62 6c |at were.|availabl|
|00000900| 65 20 61 72 65 20 73 74 | 69 6c 6c 20 69 6e 73 65 |e are st|ill inse|
|00000910| 72 74 65 64 20 69 6e 74 | 6f 20 74 68 65 20 61 72 |rted int|o the ar|
|00000920| 72 61 79 2e 0d 5c 65 6e | 64 7b 66 75 6e 63 64 65 |ray..\en|d{funcde|
|00000930| 73 63 7d 0d 0d 5c 62 65 | 67 69 6e 7b 66 75 6e 63 |sc}..\be|gin{func|
|00000940| 64 65 73 63 7d 7b 66 72 | 6f 6d 6c 69 73 74 7d 7b |desc}{fr|omlist}{|
|00000950| 6c 69 73 74 7d 0d 41 70 | 70 65 6e 64 73 20 69 74 |list}.Ap|pends it|
|00000960| 65 6d 73 20 66 72 6f 6d | 20 74 68 65 20 6c 69 73 |ems from| the lis|
|00000970| 74 2e 20 20 54 68 69 73 | 20 69 73 20 65 71 75 69 |t. This| is equi|
|00000980| 76 61 6c 65 6e 74 20 74 | 6f 0d 5c 63 6f 64 65 7b |valent t|o.\code{|
|00000990| 66 6f 72 20 78 20 69 6e | 20 5c 76 61 72 7b 6c 69 |for x in| \var{li|
|000009a0| 73 74 7d 3a 20 61 2e 61 | 70 70 65 6e 64 28 78 29 |st}: a.a|ppend(x)|
|000009b0| 7d 0d 65 78 63 65 70 74 | 20 74 68 61 74 20 69 66 |}.except| that if|
|000009c0| 20 74 68 65 72 65 20 69 | 73 20 61 20 74 79 70 65 | there i|s a type|
|000009d0| 20 65 72 72 6f 72 2c 20 | 74 68 65 20 61 72 72 61 | error, |the arra|
|000009e0| 79 20 69 73 20 75 6e 63 | 68 61 6e 67 65 64 2e 0d |y is unc|hanged..|
|000009f0| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0d 0d |\end{fun|cdesc}..|
|00000a00| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00000a10| 7b 66 72 6f 6d 73 74 72 | 69 6e 67 7d 7b 73 7d 0d |{fromstr|ing}{s}.|
|00000a20| 41 70 70 65 6e 64 73 20 | 69 74 65 6d 73 20 66 72 |Appends |items fr|
|00000a30| 6f 6d 20 74 68 65 20 73 | 74 72 69 6e 67 2c 20 69 |om the s|tring, i|
|00000a40| 6e 74 65 72 70 72 65 74 | 69 6e 67 20 74 68 65 20 |nterpret|ing the |
|00000a50| 73 74 72 69 6e 67 20 61 | 73 20 61 6e 0d 61 72 72 |string a|s an.arr|
|00000a60| 61 79 20 6f 66 20 6d 61 | 63 68 69 6e 65 20 76 61 |ay of ma|chine va|
|00000a70| 6c 75 65 73 20 28 69 2e | 65 2e 20 61 73 20 69 66 |lues (i.|e. as if|
|00000a80| 20 69 74 20 68 61 64 20 | 62 65 65 6e 20 72 65 61 | it had |been rea|
|00000a90| 64 20 66 72 6f 6d 20 61 | 0d 66 69 6c 65 20 75 73 |d from a|.file us|
|00000aa0| 69 6e 67 20 74 68 65 20 | 5c 63 6f 64 65 7b 66 72 |ing the |\code{fr|
|00000ab0| 6f 6d 66 69 6c 65 28 29 | 7d 20 6d 65 74 68 6f 64 |omfile()|} method|
|00000ac0| 29 2e 0d 5c 65 6e 64 7b | 66 75 6e 63 64 65 73 63 |)..\end{|funcdesc|
|00000ad0| 7d 0d 0d 5c 62 65 67 69 | 6e 7b 66 75 6e 63 64 65 |}..\begi|n{funcde|
|00000ae0| 73 63 7d 7b 69 6e 73 65 | 72 74 7d 7b 69 5c 2c 20 |sc}{inse|rt}{i\, |
|00000af0| 78 7d 0d 49 6e 73 65 72 | 74 20 61 20 6e 65 77 20 |x}.Inser|t a new |
|00000b00| 69 74 65 6d 20 77 69 74 | 68 20 76 61 6c 75 65 20 |item wit|h value |
|00000b10| 5c 76 61 72 7b 78 7d 20 | 69 6e 20 74 68 65 20 61 |\var{x} |in the a|
|00000b20| 72 72 61 79 20 62 65 66 | 6f 72 65 20 70 6f 73 69 |rray bef|ore posi|
|00000b30| 74 69 6f 6e 0d 5c 76 61 | 72 7b 69 7d 2e 0d 5c 65 |tion.\va|r{i}..\e|
|00000b40| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0d 0d 5c 62 |nd{funcd|esc}..\b|
|00000b50| 65 67 69 6e 7b 66 75 6e | 63 64 65 73 63 7d 7b 74 |egin{fun|cdesc}{t|
|00000b60| 6f 66 69 6c 65 7d 7b 66 | 7d 0d 57 72 69 74 65 20 |ofile}{f|}.Write |
|00000b70| 61 6c 6c 20 69 74 65 6d | 73 20 28 61 73 20 6d 61 |all item|s (as ma|
|00000b80| 63 68 69 6e 65 20 76 61 | 6c 75 65 73 29 20 74 6f |chine va|lues) to|
|00000b90| 20 74 68 65 20 66 69 6c | 65 20 6f 62 6a 65 63 74 | the fil|e object|
|00000ba0| 20 5c 76 61 72 7b 66 7d | 2e 0d 5c 65 6e 64 7b 66 | \var{f}|..\end{f|
|00000bb0| 75 6e 63 64 65 73 63 7d | 0d 0d 5c 62 65 67 69 6e |uncdesc}|..\begin|
|00000bc0| 7b 66 75 6e 63 64 65 73 | 63 7d 7b 74 6f 6c 69 73 |{funcdes|c}{tolis|
|00000bd0| 74 7d 7b 7d 0d 43 6f 6e | 76 65 72 74 20 74 68 65 |t}{}.Con|vert the|
|00000be0| 20 61 72 72 61 79 20 74 | 6f 20 61 6e 20 6f 72 64 | array t|o an ord|
|00000bf0| 69 6e 61 72 79 20 6c 69 | 73 74 20 77 69 74 68 20 |inary li|st with |
|00000c00| 74 68 65 20 73 61 6d 65 | 20 69 74 65 6d 73 2e 0d |the same| items..|
|00000c10| 5c 65 6e 64 7b 66 75 6e | 63 64 65 73 63 7d 0d 0d |\end{fun|cdesc}..|
|00000c20| 5c 62 65 67 69 6e 7b 66 | 75 6e 63 64 65 73 63 7d |\begin{f|uncdesc}|
|00000c30| 7b 74 6f 73 74 72 69 6e | 67 7d 7b 7d 0d 43 6f 6e |{tostrin|g}{}.Con|
|00000c40| 76 65 72 74 20 74 68 65 | 20 61 72 72 61 79 20 74 |vert the| array t|
|00000c50| 6f 20 61 6e 20 61 72 72 | 61 79 20 6f 66 20 6d 61 |o an arr|ay of ma|
|00000c60| 63 68 69 6e 65 20 76 61 | 6c 75 65 73 20 61 6e 64 |chine va|lues and|
|00000c70| 20 72 65 74 75 72 6e 20 | 74 68 65 0d 73 74 72 69 | return |the.stri|
|00000c80| 6e 67 20 72 65 70 72 65 | 73 65 6e 74 61 74 69 6f |ng repre|sentatio|
|00000c90| 6e 20 28 74 68 65 20 73 | 61 6d 65 20 73 65 71 75 |n (the s|ame sequ|
|00000ca0| 65 6e 63 65 20 6f 66 20 | 62 79 74 65 73 20 74 68 |ence of |bytes th|
|00000cb0| 61 74 20 77 6f 75 6c 64 | 0d 62 65 20 77 72 69 74 |at would|.be writ|
|00000cc0| 74 65 6e 20 74 6f 20 61 | 20 66 69 6c 65 20 62 79 |ten to a| file by|
|00000cd0| 20 74 68 65 20 5c 63 6f | 64 65 7b 74 6f 66 69 6c | the \co|de{tofil|
|00000ce0| 65 28 29 7d 20 6d 65 74 | 68 6f 64 2e 29 0d 5c 65 |e()} met|hod.).\e|
|00000cf0| 6e 64 7b 66 75 6e 63 64 | 65 73 63 7d 0d 0d 57 68 |nd{funcd|esc}..Wh|
|00000d00| 65 6e 20 61 6e 20 61 72 | 72 61 79 20 6f 62 6a 65 |en an ar|ray obje|
|00000d10| 63 74 20 69 73 20 70 72 | 69 6e 74 65 64 20 6f 72 |ct is pr|inted or|
|00000d20| 20 63 6f 6e 76 65 72 74 | 65 64 20 74 6f 20 61 20 | convert|ed to a |
|00000d30| 73 74 72 69 6e 67 2c 20 | 69 74 20 69 73 0d 72 65 |string, |it is.re|
|00000d40| 70 72 65 73 65 6e 74 65 | 64 20 61 73 20 5c 63 6f |presente|d as \co|
|00000d50| 64 65 7b 61 72 72 61 79 | 28 5c 76 61 72 7b 74 79 |de{array|(\var{ty|
|00000d60| 70 65 63 6f 64 65 7d 2c | 20 5c 76 61 72 7b 69 6e |pecode},| \var{in|
|00000d70| 69 74 69 61 6c 69 7a 65 | 72 7d 29 7d 2e 20 20 54 |itialize|r})}. T|
|00000d80| 68 65 0d 5c 76 61 72 7b | 69 6e 69 74 69 61 6c 69 |he.\var{|initiali|
|00000d90| 7a 65 72 7d 20 69 73 20 | 6f 6d 69 74 74 65 64 20 |zer} is |omitted |
|00000da0| 69 66 20 74 68 65 20 61 | 72 72 61 79 20 69 73 20 |if the a|rray is |
|00000db0| 65 6d 70 74 79 2c 20 6f | 74 68 65 72 77 69 73 65 |empty, o|therwise|
|00000dc0| 20 69 74 20 69 73 20 61 | 0d 73 74 72 69 6e 67 20 | it is a|.string |
|00000dd0| 69 66 20 74 68 65 20 5c | 76 61 72 7b 74 79 70 65 |if the \|var{type|
|00000de0| 63 6f 64 65 7d 20 69 73 | 20 5c 63 6f 64 65 7b 27 |code} is| \code{'|
|00000df0| 63 27 7d 2c 20 6f 74 68 | 65 72 77 69 73 65 20 69 |c'}, oth|erwise i|
|00000e00| 74 20 69 73 20 61 20 6c | 69 73 74 20 6f 66 0d 6e |t is a l|ist of.n|
|00000e10| 75 6d 62 65 72 73 2e 20 | 20 54 68 65 20 73 74 72 |umbers. | The str|
|00000e20| 69 6e 67 20 69 73 20 67 | 75 61 72 61 6e 74 65 65 |ing is g|uarantee|
|00000e30| 64 20 74 6f 20 62 65 20 | 61 62 6c 65 20 74 6f 20 |d to be |able to |
|00000e40| 62 65 20 63 6f 6e 76 65 | 72 74 65 64 20 62 61 63 |be conve|rted bac|
|00000e50| 6b 20 74 6f 0d 61 6e 20 | 61 72 72 61 79 20 77 69 |k to.an |array wi|
|00000e60| 74 68 20 74 68 65 20 73 | 61 6d 65 20 74 79 70 65 |th the s|ame type|
|00000e70| 20 61 6e 64 20 76 61 6c | 75 65 20 75 73 69 6e 67 | and val|ue using|
|00000e80| 20 72 65 76 65 72 73 65 | 20 71 75 6f 74 65 73 0d | reverse| quotes.|
|00000e90| 28 5c 63 6f 64 65 7b 60 | 60 7d 29 2e 20 20 45 78 |(\code{`|`}). Ex|
|00000ea0| 61 6d 70 6c 65 73 3a 0d | 0d 5c 62 63 6f 64 65 5c |amples:.|.\bcode\|
|00000eb0| 62 65 67 69 6e 7b 76 65 | 72 62 61 74 69 6d 7d 0d |begin{ve|rbatim}.|
|00000ec0| 61 72 72 61 79 28 27 6c | 27 29 0d 61 72 72 61 79 |array('l|').array|
|00000ed0| 28 27 63 27 2c 20 27 68 | 65 6c 6c 6f 20 77 6f 72 |('c', 'h|ello wor|
|00000ee0| 6c 64 27 29 0d 61 72 72 | 61 79 28 27 6c 27 2c 20 |ld').arr|ay('l', |
|00000ef0| 5b 31 2c 20 32 2c 20 33 | 2c 20 34 2c 20 35 5d 29 |[1, 2, 3|, 4, 5])|
|00000f00| 0d 61 72 72 61 79 28 27 | 64 27 2c 20 5b 31 2e 30 |.array('|d', [1.0|
|00000f10| 2c 20 32 2e 30 2c 20 33 | 2e 31 34 5d 29 0d 5c 65 |, 2.0, 3|.14]).\e|
|00000f20| 6e 64 7b 76 65 72 62 61 | 74 69 6d 7d 5c 65 63 6f |nd{verba|tim}\eco|
|00000f30| 64 65 0d | |de. | |
+--------+-------------------------+-------------------------+--------+--------+