home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / RLaB 1.18c / manual / eval.tex < prev    next >
LaTeX Document  |  1994-05-01  |  1.8 KB  |  [TEXT/ttxt]

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: eval.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[ttxt]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 73 65 63 74 69 6f 6e | 7b 65 76 61 6c 20 2d 2d |\section|{eval --|
|00000010| 2d 20 45 76 61 6c 75 61 | 74 65 20 65 78 70 72 65 |- Evalua|te expre|
|00000020| 73 73 69 6f 6e 7d 0d 5c | 6c 61 62 65 6c 7b 66 6e |ssion}.\|label{fn|
|00000030| 3a 65 76 61 6c 7d 0d 5c | 69 6e 64 65 78 7b 65 76 |:eval}.\|index{ev|
|00000040| 61 6c 28 29 7d 0d 5c 69 | 6e 64 65 78 7b 65 76 61 |al()}.\i|ndex{eva|
|00000050| 6c 75 61 74 65 20 65 78 | 70 72 65 73 73 69 6f 6e |luate ex|pression|
|00000060| 7d 0d 5c 62 65 67 69 6e | 7b 72 61 69 6c 7d 0d 45 |}.\begin|{rail}.E|
|00000070| 76 61 6c 20 3a 20 27 65 | 76 61 6c 27 20 27 28 27 |val : 'e|val' '('|
|00000080| 20 53 74 72 69 6e 67 20 | 27 29 27 20 3b 0d 5c 65 | String |')' ;.\e|
|00000090| 6e 64 7b 72 61 69 6c 7d | 0d 0d 5c 76 65 72 62 2b |nd{rail}|..\verb+|
|000000a0| 65 76 61 6c 2b 20 69 73 | 20 61 20 77 61 79 20 74 |eval+ is| a way t|
|000000b0| 6f 20 6d 61 6b 65 20 75 | 70 20 63 6f 6d 6d 61 6e |o make u|p comman|
|000000c0| 64 73 20 61 6e 64 20 66 | 75 6e 63 74 69 6f 6e 73 |ds and f|unctions|
|000000d0| 20 61 74 20 65 78 65 63 | 75 74 69 6f 6e 20 74 69 | at exec|ution ti|
|000000e0| 6d 65 2e 0d 59 6f 75 20 | 64 6f 20 6e 6f 74 20 67 |me..You |do not g|
|000000f0| 61 69 6e 20 6d 75 63 68 | 20 62 79 20 75 73 69 6e |ain much| by usin|
|00000100| 67 20 74 68 69 73 20 66 | 75 6e 63 74 69 6f 6e 20 |g this f|unction |
|00000110| 64 75 72 69 6e 67 20 61 | 6e 20 69 6e 74 65 72 61 |during a|n intera|
|00000120| 63 74 69 76 65 0d 73 65 | 73 73 69 6f 6e 2c 20 68 |ctive.se|ssion, h|
|00000130| 6f 77 65 76 65 72 20 69 | 74 20 63 61 6e 20 62 65 |owever i|t can be|
|00000140| 20 76 65 72 79 20 75 73 | 65 66 75 6c 20 77 68 65 | very us|eful whe|
|00000150| 6e 20 63 61 6c 6c 65 64 | 20 66 72 6f 6d 20 61 20 |n called| from a |
|00000160| 73 63 72 69 70 74 2e 20 | 0d 0d 54 68 65 20 65 78 |script. |..The ex|
|00000170| 70 72 65 73 73 69 6f 6e | 20 63 6f 6e 74 61 69 6e |pression| contain|
|00000180| 65 64 20 69 6e 20 74 68 | 65 20 73 74 72 69 6e 67 |ed in th|e string|
|00000190| 20 61 72 67 75 6d 65 6e | 74 20 69 73 20 65 76 61 | argumen|t is eva|
|000001a0| 6c 75 61 74 65 64 20 77 | 69 74 68 6f 75 74 0d 72 |luated w|ithout.r|
|000001b0| 65 67 61 72 64 20 74 6f | 20 6c 6f 63 61 6c 20 66 |egard to| local f|
|000001c0| 75 6e 63 74 69 6f 6e 73 | 2e 20 20 45 73 73 65 6e |unctions|. Essen|
|000001d0| 74 69 61 6c 6c 79 20 77 | 68 61 74 20 6f 63 63 75 |tially w|hat occu|
|000001e0| 72 73 20 69 73 20 65 71 | 75 69 76 61 6c 65 6e 74 |rs is eq|uivalent|
|000001f0| 20 74 6f 20 0d 72 65 70 | 6c 61 63 69 6e 67 20 74 | to .rep|lacing t|
|00000200| 68 65 20 5c 76 65 72 62 | 2b 65 76 61 6c 2b 20 66 |he \verb|+eval+ f|
|00000210| 75 6e 63 74 69 6f 6e 20 | 77 69 74 68 20 74 68 65 |unction |with the|
|00000220| 20 63 6f 6e 74 65 6e 74 | 73 20 6f 66 20 74 68 65 | content|s of the|
|00000230| 0d 73 74 72 69 6e 67 20 | 69 6e 20 61 20 7b 5c 65 |.string |in a {\e|
|00000240| 6d 20 67 6c 6f 62 61 6c | 7d 20 63 6f 6e 74 65 78 |m global|} contex|
|00000250| 74 2e 20 20 41 6e 79 20 | 61 73 73 69 67 6e 6d 65 |t. Any |assignme|
|00000260| 6e 74 73 20 6f 72 20 76 | 61 72 69 61 62 6c 65 0d |nts or v|ariable.|
|00000270| 6d 6f 64 69 66 69 63 61 | 74 69 6f 6e 73 20 77 69 |modifica|tions wi|
|00000280| 6c 6c 20 65 66 66 65 63 | 74 20 74 68 65 20 67 6c |ll effec|t the gl|
|00000290| 6f 62 61 6c 20 73 79 6d | 62 6f 6c 20 74 61 62 6c |obal sym|bol tabl|
|000002a0| 65 20 6f 6e 6c 79 2e 0d | 0d 5c 76 65 72 62 2b 65 |e only..|.\verb+e|
|000002b0| 76 61 6c 2b 20 64 6f 65 | 73 20 6e 6f 74 20 68 61 |val+ doe|s not ha|
|000002c0| 76 65 20 61 6e 79 20 6b | 6e 6f 77 6c 65 64 67 65 |ve any k|nowledge|
|000002d0| 20 6f 66 20 6c 6f 63 61 | 6c 20 76 61 72 69 61 62 | of loca|l variab|
|000002e0| 6c 65 73 2e 20 54 68 75 | 73 20 69 66 0d 79 6f 75 |les. Thu|s if.you|
|000002f0| 20 75 73 65 20 5c 76 65 | 72 62 2b 65 76 61 6c 2b | use \ve|rb+eval+|
|00000300| 20 77 69 74 68 69 6e 20 | 61 20 75 73 65 72 2d 64 | within |a user-d|
|00000310| 65 66 69 6e 65 64 20 66 | 75 6e 63 74 69 6f 6e 2c |efined f|unction,|
|00000320| 20 79 6f 75 20 6d 75 73 | 74 20 62 65 0d 63 61 72 | you mus|t be.car|
|00000330| 65 66 75 6c 20 6e 6f 74 | 20 74 6f 20 72 65 66 65 |eful not| to refe|
|00000340| 72 65 6e 63 65 20 74 68 | 61 74 20 66 75 6e 63 74 |rence th|at funct|
|00000350| 69 6f 6e 27 73 20 61 72 | 67 75 6d 65 6e 74 73 20 |ion's ar|guments |
|00000360| 6f 72 20 6c 6f 63 61 6c | 20 76 61 72 69 61 62 6c |or local| variabl|
|00000370| 65 73 2e 0d 0d 24 5c 4c | 6f 6e 67 72 69 67 68 74 |es...$\L|ongright|
|00000380| 61 72 72 6f 77 24 20 54 | 68 69 73 20 69 73 20 6e |arrow$ T|his is n|
|00000390| 6f 74 20 61 6e 20 5c 52 | 4c 61 42 5c 20 62 75 69 |ot an \R|LaB\ bui|
|000003a0| 6c 74 2d 69 6e 20 66 75 | 6e 63 74 69 6f 6e 2e 20 |lt-in fu|nction. |
|000003b0| 20 54 68 69 73 20 66 75 | 6e 63 74 69 6f 6e 0d 69 | This fu|nction.i|
|000003c0| 73 20 6e 6f 72 6d 61 6c | 6c 79 20 6c 6f 61 64 65 |s normal|ly loade|
|000003d0| 64 20 6f 6e 20 73 74 61 | 72 74 2d 75 70 20 66 72 |d on sta|rt-up fr|
|000003e0| 6f 6d 20 74 68 65 20 5c | 76 65 72 62 2b 65 76 61 |om the \|verb+eva|
|000003f0| 6c 2e 72 2b 20 66 69 6c | 65 20 69 6e 20 74 68 65 |l.r+ fil|e in the|
|00000400| 0d 73 74 61 6e 64 61 72 | 64 20 5c 76 65 72 62 2b |.standar|d \verb+|
|00000410| 72 6c 69 62 2b 20 64 69 | 72 65 63 74 6f 72 79 2e |rlib+ di|rectory.|
|00000420| 20 55 73 65 20 6f 66 20 | 74 68 65 20 5c 76 65 72 | Use of |the \ver|
|00000430| 62 2b 2d 72 2b 20 6f 70 | 74 69 6f 6e 2c 20 69 6e |b+-r+ op|tion, in|
|00000440| 63 6f 72 72 65 63 74 6c | 79 20 0d 73 65 74 74 69 |correctl|y .setti|
|00000450| 6e 67 20 74 68 65 20 5c | 76 65 72 62 2b 52 4c 41 |ng the \|verb+RLA|
|00000460| 42 5f 4c 49 42 5f 44 49 | 52 2b 20 65 6e 76 69 72 |B_LIB_DI|R+ envir|
|00000470| 6f 6e 6d 65 6e 74 61 6c | 20 76 61 72 69 61 62 6c |onmental| variabl|
|00000480| 65 2c 20 6f 72 20 6d 6f | 64 69 66 79 69 6e 67 0d |e, or mo|difying.|
|00000490| 5c 76 65 72 62 2b 65 76 | 61 6c 2e 72 2b 20 6d 61 |\verb+ev|al.r+ ma|
|000004a0| 79 20 6d 61 6b 65 20 74 | 68 69 73 20 66 75 6e 63 |y make t|his func|
|000004b0| 74 69 6f 6e 20 75 6e 61 | 76 61 69 6c 61 62 6c 65 |tion una|vailable|
|000004c0| 2e 0d 0d 5c 70 61 72 61 | 67 72 61 70 68 7b 45 78 |...\para|graph{Ex|
|000004d0| 61 6d 70 6c 65 7d 0d 5c | 69 6e 64 65 78 7b 65 78 |ample}.\|index{ex|
|000004e0| 61 6d 70 6c 65 20 6f 66 | 20 65 76 61 6c 28 29 7d |ample of| eval()}|
|000004f0| 0d 5c 69 6e 64 65 78 7b | 65 76 61 6c 28 29 21 65 |.\index{|eval()!e|
|00000500| 78 61 6d 70 6c 65 7d 0d | 5c 62 65 67 69 6e 7b 76 |xample}.|\begin{v|
|00000510| 65 72 62 61 74 69 6d 7d | 0d 3e 20 65 76 61 6c 28 |erbatim}|.> eval(|
|00000520| 22 61 20 3d 20 63 6f 73 | 28 30 29 22 29 0d 20 61 |"a = cos|(0)"). a|
|00000530| 20 3d 0d 20 20 20 20 20 | 20 20 20 31 0d 20 20 20 | =. | 1. |
|00000540| 20 20 20 20 20 30 0d 3e | 20 65 76 61 6c 28 22 61 | 0.>| eval("a|
|00000550| 20 3d 20 73 69 6e 28 73 | 71 72 74 28 32 29 2f 32 | = sin(s|qrt(2)/2|
|00000560| 29 22 29 3b 0d 20 61 20 | 3d 0d 20 20 20 20 20 30 |)");. a |=. 0|
|00000570| 2e 36 35 0d 3e 20 65 76 | 61 6c 28 22 62 20 3d 20 |.65.> ev|al("b = |
|00000580| 74 61 6e 28 33 29 3b 22 | 29 0d 20 20 20 20 20 20 |tan(3);"|). |
|00000590| 20 20 30 0d 3e 20 62 0d | 20 62 20 3d 0d 20 20 20 | 0.> b.| b =. |
|000005a0| 2d 30 2e 31 34 33 0d 3e | 20 70 72 69 6e 74 66 28 |-0.143.>| printf(|
|000005b0| 20 22 45 6e 74 65 72 20 | 61 20 66 75 6e 63 74 69 | "Enter |a functi|
|000005c0| 6f 6e 3a 20 22 20 29 3b | 20 78 20 3d 20 67 65 74 |on: " );| x = get|
|000005d0| 6c 69 6e 65 28 20 22 73 | 74 64 69 6e 22 20 29 3b |line( "s|tdin" );|
|000005e0| 0d 45 6e 74 65 72 20 61 | 20 66 75 6e 63 74 69 6f |.Enter a| functio|
|000005f0| 6e 3a 20 73 71 72 74 0d | 3e 20 2f 2f 20 74 68 69 |n: sqrt.|> // thi|
|00000600| 73 20 63 6f 75 6c 64 20 | 62 65 20 69 6e 20 61 20 |s could |be in a |
|00000610| 66 75 6e 63 74 69 6f 6e | 0d 3e 20 65 76 61 6c 28 |function|.> eval(|
|00000620| 22 74 6d 70 20 3d 20 22 | 20 2b 20 78 2e 5b 31 5d |"tmp = "| + x.[1]|
|00000630| 20 2b 20 22 28 22 20 2b | 20 22 33 22 20 2b 20 22 | + "(" +| "3" + "|
|00000640| 29 22 20 29 3b 0d 20 74 | 6d 70 20 3d 0d 20 20 20 |)" );. t|mp =. |
|00000650| 20 20 31 2e 37 33 0d 3e | 20 70 72 69 6e 74 66 28 | 1.73.>| printf(|
|00000660| 20 22 45 6e 74 65 72 20 | 61 20 66 75 6e 63 74 69 | "Enter |a functi|
|00000670| 6f 6e 3a 20 22 20 29 3b | 20 78 20 3d 20 67 65 74 |on: " );| x = get|
|00000680| 6c 69 6e 65 28 20 22 73 | 74 64 69 6e 22 20 29 3b |line( "s|tdin" );|
|00000690| 0d 45 6e 74 65 72 20 61 | 20 66 75 6e 63 74 69 6f |.Enter a| functio|
|000006a0| 6e 3a 20 74 61 6e 68 0d | 3e 20 65 76 61 6c 28 22 |n: tanh.|> eval("|
|000006b0| 74 6d 70 20 3d 20 22 20 | 2b 20 78 2e 5b 31 5d 20 |tmp = " |+ x.[1] |
|000006c0| 2b 20 22 28 22 20 2b 20 | 22 33 22 20 2b 20 22 29 |+ "(" + |"3" + ")|
|000006d0| 22 20 29 3b 0d 20 74 6d | 70 20 3d 0d 20 20 20 20 |" );. tm|p =. |
|000006e0| 30 2e 39 39 35 0d 5c 65 | 6e 64 7b 76 65 72 62 61 |0.995.\e|nd{verba|
|000006f0| 74 69 6d 7d 0d 0d 5c 6e | 65 77 70 61 67 65 0d 0d |tim}..\n|ewpage..|
|00000700| 0d 0d 0d | |... | |
+--------+-------------------------+-------------------------+--------+--------+