picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

refI.html (15690B)


      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
      2 <html lang="en">
      3 <head>
      4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      5 <title>I</title>
      6 <link rel="stylesheet" href="doc.css" type="text/css">
      7 </head>
      8 <body>
      9 
     10 <h1>I</h1>
     11 
     12 <dl>
     13 
     14 <dt><a name="+Idx"><code>+Idx</code></a>
     15 <dd>Prefix class for maintaining non-unique full-text indexes to <code><a
     16 href="refS.html#+String">+String</a></code> relations, a subclass of <code><a
     17 href="refR.html#+Ref">+Ref</a></code>. Accepts optional arguments for the
     18 minimally indexed substring length (defaults to 3), and a <code><a
     19 href="refH.html#+Hook">+Hook</a></code> attribute. Often used in combination
     20 with the <code><a href="refS.html#+Sn">+Sn</a></code> soundex index, or the
     21 <code><a href="refF.html#+Fold">+Fold</a></code> index prefix classes. See also
     22 <a href="ref.html#dbase">Database</a>.
     23 
     24 <pre><code>
     25 (rel nm (+Sn +Idx +String))  # Name
     26 </code></pre>
     27 
     28 <dt><a name="+IdxFold"><code>+IdxFold</code></a>
     29 <dd>Prefix class for maintaining non-unique indexes to subsequent substrings of
     30 the <code><a href="refF.html#fold">fold</a></code>ed individual words of
     31 <code><a href="refS.html#+String">+String</a></code> relations. Accepts optional
     32 arguments for the minimally indexed substring length (defaults to 3), and a
     33 <code><a href="refH.html#+Hook">+Hook</a></code> attribute. See also <code><a
     34 href="refI.html#+Idx">+Idx</a></code> and <a href="ref.html#dbase">Database</a>.
     35 
     36 <pre><code>
     37 (rel nm (+IdxFold +String))            # Item Description
     38 </code></pre>
     39 
     40 <dt><a name="+index"><code>+index</code></a>
     41 <dd>Abstract base class of all database B-Tree index relations (prefix classes
     42 for <code><a href="refR.html#+relation">+relation</a></code>s). The class
     43 hierarchy includes <code><a href="refK.html#+Key">+Key</a></code>, <code><a
     44 href="refR.html#+Ref">+Ref</a></code>, <code><a
     45 href="refI.html#+Idx">+Idx</a></code> and <code><a
     46 href="refI.html#+IdxFold">+IdxFold</a></code>. See also <a
     47 href="ref.html#dbase">Database</a>.
     48 
     49 <pre><code>
     50 (isa '+index Rel)  # Check for an index relation
     51 </code></pre>
     52 
     53 <dt><a name="id"><code>(id 'num ['num]) -> sym</code></a>
     54 <dt><code>(id 'sym [NIL]) -> num</code>
     55 <dt><code>(id 'sym T) -> (num . num)</code>
     56 <dd>Converts one or two numbers to an external symbol, or an external symbol to
     57 a number or a pair of numbers.
     58 
     59 <pre><code>
     60 : (id 7)
     61 -> {7}
     62 : (id 1 2)
     63 -> {2}
     64 : (id '{1-2})
     65 -> 2
     66 : (id '{1-2} T)
     67 -> (1 . 2)
     68 </code></pre>
     69 
     70 <dt><a name="idx"><code>(idx 'var 'any 'flg) -> lst<br>
     71 (idx 'var 'any) -> lst<br>
     72 (idx 'var) -> lst</code></a>
     73 <dd>Maintains an index tree in <code>var</code>, and checks for the existence of
     74 <code>any</code>. If <code>any</code> is contained in <code>var</code>, the
     75 corresponding subtree is returned, otherwise <code>NIL</code>. In the first
     76 form, <code>any</code> is destructively inserted into the tree if
     77 <code>flg</code> is non-<code>NIL</code> (and <code>any</code> was not already
     78 there), or deleted from the tree if <code>flg</code> is <code>NIL</code>. The
     79 second form only checks for existence, but does not change the index tree. In
     80 the third form (when called with a single <code>var</code> argument) the
     81 contents of the tree are returned as a sorted list. If all elements are inserted
     82 in sorted order, the tree degenerates into a linear list. See also <code><a
     83 href="refL.html#lup">lup</a></code>, <code><a
     84 href="refH.html#hash">hash</a></code>, <code><a
     85 href="refD.html#depth">depth</a></code>, <code><a
     86 href="refS.html#sort">sort</a></code>, <code><a
     87 href="refB.html#balance">balance</a></code> and <code><a
     88 href="refM.html#member">member</a></code>.
     89 
     90 <pre><code>
     91 : (idx 'X 'd T)                              # Insert data
     92 -> NIL
     93 : (idx 'X 2 T)
     94 -> NIL
     95 : (idx 'X '(a b c) T)
     96 -> NIL
     97 : (idx 'X 17 T)
     98 -> NIL
     99 : (idx 'X 'A T)
    100 -> NIL
    101 : (idx 'X 'd T)
    102 -> (d (2 NIL 17 NIL A) (a b c))              # 'd' already existed
    103 : (idx 'X T T)
    104 -> NIL
    105 : X                                          # View the index tree
    106 -> (d (2 NIL 17 NIL A) (a b c) NIL T)
    107 : (idx 'X 'A)                                # Check for 'A'
    108 -> (A)
    109 : (idx 'X 'B)                                # Check for 'B'
    110 -> NIL
    111 : (idx 'X)
    112 -> (2 17 A d (a b c) T)                      # Get list
    113 : (idx 'X 17 NIL)                            # Delete '17'
    114 -> (17 NIL A)
    115 : X
    116 -> (d (2 NIL A) (a b c) NIL T)               # View it again
    117 : (idx 'X)
    118 -> (2 A d (a b c) T)                         # '17' is deleted
    119 </code></pre>
    120 
    121 <dt><a name="if"><code>(if 'any1 'any2 . prg) -> any</code></a>
    122 <dd>Conditional execution: If the condition <code>any1</code> evaluates to
    123 non-<code>NIL</code>, <code>any2</code> is evaluated and returned. Otherwise,
    124 <code>prg</code> is executed and the result returned. See also <code><a
    125 href="refC.html#cond">cond</a></code>, <code><a
    126 href="refW.html#when">when</a></code> and <code><a
    127 href="refI.html#if2">if2</a></code>.
    128 
    129 <pre><code>
    130 : (if (> 4 3) (println 'OK) (println 'Bad))
    131 OK
    132 -> OK
    133 : (if (> 3 4) (println 'OK) (println 'Bad))
    134 Bad
    135 -> Bad
    136 </code></pre>
    137 
    138 <dt><a name="if2"><code>(if2 'any1 'any2 'any3 'any4 'any5 . prg) -> any</code></a>
    139 <dd>Four-way conditional execution for two conditions: If both conditions
    140 <code>any1</code> and <code>any2</code> evaluate to non-<code>NIL</code>,
    141 <code>any3</code> is evaluated and returned. Otherwise, <code>any4</code> or
    142 <code>any5</code> is evaluated and returned if <code>any1</code> or
    143 <code>any2</code> evaluate to non-<code>NIL</code>, respectively. If none of the
    144 conditions evaluate to non-<code>NIL</code>, <code>prg</code> is executed and
    145 the result returned. See also <code><a href="refI.html#if">if</a></code> and
    146 <code><a href="refC.html#cond">cond</a></code>.
    147 
    148 <pre><code>
    149 : (if2 T T 'both 'first 'second 'none)
    150 -> both
    151 : (if2 T NIL 'both 'first 'second 'none)
    152 -> first
    153 : (if2 NIL T 'both 'first 'second 'none)
    154 -> second
    155 : (if2 NIL NIL 'both 'first 'second 'none)
    156 -> none
    157 </code></pre>
    158 
    159 <dt><a name="ifn"><code>(ifn 'any1 'any2 . prg) -> any</code></a>
    160 <dd>Conditional execution ("If not"): If the condition <code>any1</code>
    161 evaluates to <code>NIL</code>, <code>any2</code> is evaluated and returned.
    162 Otherwise, <code>prg</code> is executed and the result returned.
    163 
    164 <pre><code>
    165 : (ifn (= 3 4) (println 'OK) (println 'Bad))
    166 OK
    167 -> OK
    168 </code></pre>
    169 
    170 <dt><a name="import"><code>(import . lst) -> NIL</code></a>
    171 <dd>Wrapper function for <code><a href="refI.html#intern">intern</a></code>.
    172 Typically used to import symbols from other namespaces, as created by <code><a
    173 href="refS.html#symbols">symbols</a></code>. <code>lst</code> should be a list
    174 of symbols. An import conflict error is issued when a symbol with the same name
    175 already exists in the current namespace. See also <code><a
    176 href="refP.html#pico">pico</a></code> and <code><a
    177 href="refL.html#local">local</a></code>.
    178 
    179 <pre><code>
    180 : (import libA~foo libB~bar)
    181 -> NIL
    182 </code></pre>
    183 
    184 <dt><a name="in"><code>(in 'any . prg) -> any</code></a>
    185 <dd>Opens <code>any</code> as input channel during the execution of
    186 <code>prg</code>. The current input channel will be saved and restored
    187 appropriately. If the argument is <code>NIL</code>, standard input is used. If
    188 the argument is a symbol, it is used as a file name (opened for reading
    189 <i>and</i> writing if the first character is "<code>+</code>"). If it is a
    190 positive number, it is used as the descriptor of an open file. If it is a
    191 negative number, the saved input channel such many levels above the current one
    192 is used. Otherwise (if it is a list), it is taken as a command with arguments,
    193 and a pipe is opened for input. See also <code><a
    194 href="refI.html#ipid">ipid</a></code>, <code><a
    195 href="refC.html#call">call</a></code>, <code><a
    196 href="refL.html#load">load</a></code>, <code><a
    197 href="refF.html#file">file</a></code>, <code><a
    198 href="refO.html#out">out</a></code>, <code><a
    199 href="refE.html#err">err</a></code>, <code><a
    200 href="refP.html#poll">poll</a></code>, <code><a
    201 href="refP.html#pipe">pipe</a></code> and <code><a
    202 href="refC.html#ctl">ctl</a></code>.
    203 
    204 <pre><code>
    205 : (in "a" (list (read) (read) (read)))  # Read three items from file "a"
    206 -> (123 (a b c) def)
    207 </code></pre>
    208 
    209 <dt><a name="inc"><code>(inc 'num) -> num<br>
    210 (inc 'var ['num]) -> num</code></a>
    211 <dd>The first form returns the value of <code>num</code> incremented by 1. The
    212 second form increments the <code>VAL</code> of <code>var</code> by 1, or by
    213 <code>num</code>. If the first argument is <code>NIL</code>, it is returned
    214 immediately. <code>(inc Num)</code> is equivalent to <code>(+ Num 1)</code> and
    215 <code>(inc 'Var)</code> is equivalent to <code>(set 'Var (+ Var 1))</code>. See
    216 also <code><a href="refD.html#dec">dec</a></code> and <code><a
    217 href="ref_.html#+">+</a></code>.
    218 
    219 <pre><code>
    220 : (inc 7)
    221 -> 8
    222 : (inc -1)
    223 -> 0
    224 : (zero N)
    225 -> 0
    226 : (inc 'N)
    227 -> 1
    228 : (inc 'N 7)
    229 -> 8
    230 : N
    231 -> 8
    232 
    233 : (setq L (1 2 3 4))
    234 -> (1 2 3 4)
    235 : (inc (cdr L))
    236 -> 3
    237 : L
    238 -> (1 3 3 4)
    239 </code></pre>
    240 
    241 <dt><a name="inc!"><code>(inc! 'obj 'sym ['num]) -> num</code></a>
    242 <dd><a href="ref.html#trans">Transaction</a> wrapper function for <code><a
    243 href="refI.html#inc">inc</a></code>. <code>num</code> defaults to 1. Note that
    244 for incrementing a property value of an entity typically the <code><a
    245 href="refE.html#entityMesssages">inc!></a></code> message is used. See also
    246 <code><a href="refN.html#new!">new!</a></code>, <code><a
    247 href="refS.html#set!">set!</a></code> and <code><a
    248 href="refP.html#put!">put!</a></code>.
    249 
    250 <pre><code>
    251 (inc! Obj 'cnt 0)  # Incrementing a property of a non-entity object
    252 </code></pre>
    253 
    254 <dt><a name="index"><code>(index 'any 'lst) -> cnt | NIL</code></a>
    255 <dd>Returns the <code>cnt</code> position of <code>any</code> in
    256 <code>lst</code>, or <code>NIL</code> if it is not found. See also <code><a
    257 href="refO.html#offset">offset</a></code>.
    258 
    259 <pre><code>
    260 : (index 'c '(a b c d e f))
    261 -> 3
    262 : (index '(5 6) '((1 2) (3 4) (5 6) (7 8)))
    263 -> 3
    264 </code></pre>
    265 
    266 <dt><a name="info"><code>(info 'any ['flg]) -> (cnt|T dat . tim)</code></a>
    267 <dd>Returns information about a file with the name <code>any</code>: The current
    268 size <code>cnt</code> in bytes, and the modification date and time (UTC). For
    269 directories, <code>T</code> is returned instead of the size. If <code>flg</code>
    270 is non-<code>NIL</code> and <code>any</code> is the name of a symbolic link,
    271 then the link itself is used, not the file that it refers to. See also <code><a
    272 href="refD.html#dir">dir</a></code>, <code><a
    273 href="refD.html#date">date</a></code>, <code><a
    274 href="refT.html#time">time</a></code> and <code><a
    275 href="refL.html#lines">lines</a></code>.
    276 
    277 <pre><code>
    278 $ ls -l x.l
    279 -rw-r--r--   1 abu      users         208 Jun 17 08:58 x.l
    280 $ pil +
    281 : (info "x.l")
    282 -> (208 730594 . 32315)
    283 : (stamp 730594 32315)
    284 -> "2000-06-17 08:58:35"
    285 </code></pre>
    286 
    287 <dt><a name="init"><code>(init 'tree ['any1] ['any2]) -> lst</code></a>
    288 <dd>Initializes a structure for stepping iteratively through a database tree.
    289 <code>any1</code> and <code>any2</code> may specify a range of keys. If
    290 <code>any2</code> is greater than <code>any1</code>, the traversal will be in
    291 opposite direction. See also <code><a href="refT.html#tree">tree</a></code>,
    292 <code><a href="refS.html#step">step</a></code>, <code><a
    293 href="refI.html#iter">iter</a></code> and <code><a
    294 href="refS.html#scan">scan</a></code>.
    295 
    296 <pre><code>
    297 : (init (tree 'nr '+Item) 3 5)
    298 -> (((3 . 5) ((3 NIL . {3-3}) (4 NIL . {3-4}) (5 NIL . {3-5}) (6 NIL . {3-6}) (7 NIL . {3-8}))))
    299 </code></pre>
    300 
    301 <dt><a name="insert"><code>(insert 'cnt 'lst 'any) -> lst</code></a>
    302 <dd>Inserts <code>any</code> into <code>lst</code> at position <code>cnt</code>.
    303 This is a non-destructive operation. See also <code><a
    304 href="refR.html#remove">remove</a></code>, <code><a
    305 href="refP.html#place">place</a></code>, <code><a
    306 href="refA.html#append">append</a></code>, <code><a
    307 href="refD.html#delete">delete</a></code> and <code><a
    308 href="refR.html#replace">replace</a></code>.
    309 
    310 <pre><code>
    311 : (insert 3 '(a b c d e) 777)
    312 -> (a b 777 c d e)
    313 : (insert 1 '(a b c d e) 777)
    314 -> (777 a b c d e)
    315 : (insert 9 '(a b c d e) 777)
    316 -> (a b c d e 777)
    317 </code></pre>
    318 
    319 <dt><a name="intern"><code>(intern 'sym) -> sym</code></a>
    320 <dd>Creates or finds an internal symbol. If a symbol with the name
    321 <code>sym</code> is already intern, it is returned. Otherwise, <code>sym</code>
    322 is interned and returned. See also <code><a
    323 href="refS.html#symbols">symbols</a></code>, <code><a
    324 href="refZ.html#zap">zap</a></code>, <code><a
    325 href="refE.html#extern">extern</a></code> and <code><a
    326 href="ref_.html#====">====</a></code>.
    327 
    328 <pre><code>
    329 : (intern "abc")
    330 -> abc
    331 : (intern 'car)
    332 -> car
    333 : ((intern (pack "c" "a" "r")) (1 2 3))
    334 -> 1
    335 </code></pre>
    336 
    337 <dt><a name="ipid"><code>(ipid) -> pid | NIL</code></a>
    338 <dd>Returns the corresponding process ID when the current input channel is
    339 reading from a pipe, otherwise <code>NIL</code>. See also <code><a
    340 href="refO.html#opid">opid</a></code>, <code><a
    341 href="refI.html#in">in</a></code>, <code><a
    342 href="refP.html#pipe">pipe</a></code> and <code><a
    343 href="refL.html#load">load</a></code>.
    344 
    345 <pre><code>
    346 : (in '(ls "-l") (println (line T)) (kill (ipid)))
    347 "total 7364"
    348 -> T
    349 </code></pre>
    350 
    351 <dt><a name="isa"><code>(isa 'cls|typ 'obj) -> obj | NIL</code></a>
    352 <dd>Returns <code>obj</code> when it is an object that inherits from
    353 <code>cls</code> or <code>type</code>. See also <a href="ref.html#oop">OO
    354 Concepts</a>, <code><a href="refC.html#class">class</a></code>, <code><a
    355 href="refT.html#type">type</a></code>, <code><a
    356 href="refN.html#new">new</a></code> and <code><a
    357 href="refO.html#object">object</a></code>.
    358 
    359 <pre><code>
    360 : (isa '+Address Obj)
    361 -> {1-17}
    362 : (isa '(+Male +Person) Obj)
    363 -> NIL
    364 </code></pre>
    365 
    366 <dt><a name="isa/2"><code>isa/2</code></a>
    367 <dd><a href="ref.html#pilog">Pilog</a> predicate that succeeds if the second
    368 argument is of the type or class given by the first argument, according to the
    369 <code><a href="refI.html#isa">isa</a></code> function. Typically used in
    370 <code><a href="refD.html#db/3">db/3</a></code> or <code><a
    371 href="refS.html#select/3">select/3</a></code> database queries. See also
    372 <code><a href="refS.html#same/3">same/3</a></code>, <code><a
    373 href="refB.html#bool/3">bool/3</a></code>, <code><a
    374 href="refR.html#range/3">range/3</a></code>, <code><a
    375 href="refH.html#head/3">head/3</a></code>, <code><a
    376 href="refF.html#fold/3">fold/3</a></code>, <code><a
    377 href="refP.html#part/3">part/3</a></code> and <code><a
    378 href="refT.html#tolr/3">tolr/3</a></code>.
    379 
    380 <pre><code>
    381 : (? (db nm +Person @Prs) (isa +Woman @Prs) (val @Nm @Prs nm))
    382  @Prs={2-Y} @Nm="Alexandra of Denmark"
    383  @Prs={2-1I} @Nm="Alice Maud Mary"
    384  @Prs={2-F} @Nm="Anne"
    385  @Prs={2-j} @Nm="Augusta Victoria".   # Stop
    386 </code></pre>
    387 
    388 <dt><a name="iter"><code>(iter 'tree ['fun] ['any1] ['any2] ['flg])</code></a>
    389 <dd>Iterates through a database tree by applying <code>fun</code> to all values.
    390 <code>fun</code> defaults to <code><a
    391 href="refP.html#println">println</a></code>. <code>any1</code> and
    392 <code>any2</code> may specify a range of keys. If <code>any2</code> is greater
    393 than <code>any1</code>, the traversal will be in opposite direction. Note that
    394 the keys need not to be atomic, depending on the application's index structure.
    395 If <code>flg</code> is non-<code>NIL</code>, partial keys are skipped. See also
    396 <code><a href="refT.html#tree">tree</a></code>, <code><a
    397 href="refS.html#scan">scan</a></code>, <code><a
    398 href="refI.html#init">init</a></code> and <code><a
    399 href="refS.html#step">step</a></code>.
    400 
    401 <pre><code>
    402 : (iter (tree 'nr '+Item))
    403 {3-1}
    404 {3-2}
    405 {3-3}
    406 {3-4}
    407 {3-5}
    408 {3-6}
    409 {3-8}
    410 -> {7-1}
    411 : (iter (tree 'nr '+Item) '((This) (println (: nm))))
    412 "Main Part"
    413 "Spare Part"
    414 "Auxiliary Construction"
    415 "Enhancement Additive"
    416 "Metal Fittings"
    417 "Gadget Appliance"
    418 "Testartikel"
    419 -> {7-1}
    420 </code></pre>
    421 
    422 </dl>
    423 
    424 </body>
    425 </html>