picolisp

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

refU.html (13735B)


      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>U</title>
      6 <link rel="stylesheet" href="doc.css" type="text/css">
      7 </head>
      8 <body>
      9 
     10 <h1>U</h1>
     11 
     12 <dl>
     13 
     14 <dt><a name="*Uni"><code>*Uni</code></a>
     15 <dd>A global variable holding an <code><a href="refI.html#idx">idx</a></code>
     16 tree, with all unique data that were collected with the comma (<code>,</code>)
     17 read-macro. Typically used for localization. See also <code><a
     18 href="ref.html#macro-io">Read-Macros</a></code> and <code><a
     19 href="refL.html#locale">locale</a></code>.
     20 
     21 <pre><code>
     22 : (off *Uni)            # Clear
     23 -> NIL
     24 : ,"abc"                # Collect a transient symbol
     25 -> "abc"
     26 : ,(1 2 3)              # Collect a list
     27 -> (1 2 3)
     28 : *Uni
     29 -> ("abc" NIL (1 2 3))
     30 </code></pre>
     31 
     32 <dt><a name="+UB"><code>+UB</code></a>
     33 <dd>Prefix class for <code><a href="refA.html#+Aux">+Aux</a></code> to maintain
     34 an UB-Tree index instead of the direct values. This allows efficient range
     35 access to multidimensional data. Only numeric keys are supported. See also <a
     36 href="ref.html#dbase">Database</a>.
     37 
     38 <pre><code>
     39 (class +Pos +Entity)
     40 (rel x (+UB +Aux +Ref +Number) (y z))
     41 (rel y (+Number))
     42 (rel z (+Number))
     43 
     44 : (scan (tree 'x '+Pos))
     45 ...
     46 (664594005183881683 . {B}) {B}
     47 (899018453307525604 . {C}) {C}  # UBKEY of (516516 690628 706223)
     48 (943014863198293414 . {2}) {2}
     49 (988682500781514058 . {A}) {A}
     50 (994667870851824704 . {8}) {8}
     51 (1016631364991047263 . {:}) {:}
     52 ...
     53 
     54 : (show '{C})
     55 {C} (+Pos)
     56    z 706223
     57    y 690628
     58    x 516516
     59 -> {C}
     60 
     61 # Discrete queries work the same way as without the +UB prefix
     62 : (db 'x '+Pos 516516 'y 690628 'z 706223)
     63 -> {C}
     64 : (aux 'x '+Pos 516516 690628 706223)
     65 -> {C}
     66 : (? (db x +Pos (516516 690628 706223) @Pos))
     67  @Pos={C}
     68 -> NIL
     69 
     70 # Efficient range queries are are possible now
     71 : (?
     72    @X (416511 . 616519)
     73    @Y (590621 . 890629)
     74    @Z (606221 . 906229)
     75    (select (@@)
     76       ((x +Pos (@X @Y @Z)))   # Range query
     77       (range @X @@ x)         # Filter
     78       (range @Y @@ y)
     79       (range @Z @@ z) ) )
     80  @X=(416511 . 616519) @Y=(590621 . 890629) @Z=(606221 . 906229) @@={C}
     81  @X=(416511 . 616519) @Y=(590621 . 890629) @Z=(606221 . 906229) @@={8}
     82 </code></pre>
     83 
     84 <dt><a name="u"><code>(u) -> T</code></a>
     85 <dd>(Debug mode only) Removes <code><a href="ref_.html#!">!</a></code> all
     86 breakpoints in all subexpressions of the current breakpoint. Typically used when
     87 single-stepping a function or method with <code><a
     88 href="refD.html#debug">debug</a></code>. See also <code><a
     89 href="refD.html#d">d</a></code> and <code><a
     90 href="refU.html#unbug">unbug</a></code>.
     91 
     92 <pre><code>
     93 ! (u)                         # Unbug subexpression(s) at breakpoint
     94 -> T
     95 </code></pre>
     96 
     97 <dt><a name="udp"><code>(udp 'any1 'any2 'any3) -> any</code></a>
     98 <dt><code>(udp 'cnt) -> any</code>
     99 <dd>Simple unidirectional sending/receiving of UDP packets. In the first form,
    100 <code>any3</code> is sent to a UDP server listening at host <code>any1</code>,
    101 port <code>any2</code>. In the second form, one item is received from a UDP
    102 socket <code>cnt</code>, established with <code><a
    103 href="refP.html#port">port</a></code>. See also <code><a
    104 href="refL.html#listen">listen</a></code> and <code><a
    105 href="refC.html#connect">connect</a></code>.
    106 
    107 <pre><code>
    108 # First session
    109 : (port T 6666)
    110 -> 3
    111 : (udp 3)  # Receive a datagram
    112 
    113 # Second session (on the same machine)
    114 : (udp "localhost" 6666 '(a b c))
    115 -> (a b c)
    116 
    117 # First session
    118 -> (a b c)
    119 </code></pre>
    120 
    121 <dt><a name="ultimo"><code>(ultimo 'y 'm) -> cnt</code></a>
    122 <dd>Returns the <code><a href="refD.html#date">date</a></code> of the last day
    123 of the month <code>m</code> in the year <code>y</code>. See also <code><a
    124 href="refD.html#day">day</a></code> and <code><a
    125 href="refW.html#week">week</a></code>.
    126 
    127 <pre><code>
    128 : (date (ultimo 2007 1))
    129 -> (2007 1 31)
    130 : (date (ultimo 2007 2))
    131 -> (2007 2 28)
    132 : (date (ultimo 2004 2))
    133 -> (2004 2 29)
    134 : (date (ultimo 2000 2))
    135 -> (2000 2 29)
    136 : (date (ultimo 1900 2))
    137 -> (1900 2 28)
    138 </code></pre>
    139 
    140 <dt><a name="unbug"><code>(unbug 'sym) -> T</code></a>
    141 <dt><code>(unbug 'sym 'cls) -> T</code>
    142 <dt><code>(unbug '(sym . cls)) -> T</code>
    143 <dd>(Debug mode only) Removes all <code><a href="ref_.html#!">!</a></code>
    144 breakpoints in the function or method body of sym, as inserted with <code><a
    145 href="refD.html#debug">debug</a></code> or <code><a
    146 href="refD.html#d">d</a></code>, or directly with <code><a
    147 href="refE.html#edit">edit</a></code>. See also <code><a
    148 href="refU.html#u">u</a></code>.
    149 
    150 <pre><code>
    151 : (pp 'tst)
    152 (de tst (N)
    153    (! println (+ 3 N)) )         # 'tst' has a breakpoint '!'
    154 -> tst
    155 : (unbug 'tst)                   # Unbug it
    156 -> T
    157 : (pp 'tst)                      # Restore
    158 (de tst (N)
    159    (println (+ 3 N)) )
    160 </code></pre>
    161 
    162 <dt><a name="undef"><code>(undef 'sym) -> fun</code></a>
    163 <dt><code>(undef 'sym 'cls) -> fun</code>
    164 <dt><code>(undef '(sym . cls)) -> fun</code>
    165 <dd>Undefines the function or method <code>sym</code>. Returns the previous
    166 definition. See also <code><a href="refD.html#de">de</a></code>, <code><a
    167 href="refD.html#dm">dm</a></code>, <code><a href="refD.html#def">def</a></code>
    168 and <code><a href="refR.html#redef">redef</a></code>.
    169 
    170 <pre><code>
    171 : (de hello () "Hello world!")
    172 -> hello
    173 : hello
    174 -> (NIL "Hello world!")
    175 : (undef 'hello)
    176 -> (NIL "Hello world!")
    177 : hello
    178 -> NIL
    179 </code></pre>
    180 
    181 <dt><a name="unify"><code>(unify 'any) -> lst</code></a>
    182 <dd>Unifies <code>any</code> with the current <a href="ref.html#pilog">Pilog</a>
    183 environment at the current level and with a value of <code>NIL</code>, and
    184 returns the new environment or <code>NIL</code> if not successful. See also
    185 <code><a href="refP.html#prove">prove</a></code> and <code><a
    186 href="ref_.html#->">-&gt</a></code>.
    187 
    188 <pre><code>
    189 : (? (^ @A (unify '(@B @C))))
    190  @A=(((NIL . @C) 0 . @C) ((NIL . @B) 0 . @B) T)
    191 </code></pre>
    192 
    193 <dt><a name="uniq"><code>(uniq 'lst) -> lst</code></a>
    194 <dd>Returns a unique list, by eleminating all duplicate elements from
    195 <code>lst</code>. See also <a href="ref.html#cmp">Comparing</a>, <code><a
    196 href="refS.html#sort">sort</a></code> and <code><a
    197 href="refG.html#group">group</a></code>.
    198 
    199 <pre><code>
    200 : (uniq (2 4 6 1 2 3 4 5 6 1 3 5))
    201 -> (2 4 6 1 3 5)
    202 </code></pre>
    203 
    204 <dt><a name="uniq/2"><code>uniq/2</code></a>
    205 <dd><a href="ref.html#pilog">Pilog</a> predicate that succeeds if the first
    206 argument is not yet stored in the second argument's index structure. <code><a
    207 href="refI.html#idx">idx</a></code> is used internally storing for the values
    208 and checking for uniqueness. See also <code><a
    209 href="refM.html#member/2">member/2</a></code>.
    210 
    211 <pre><code>
    212 : (? (uniq a @Z))       # Remember 'a'
    213  @Z=NIL                 # Succeeded
    214 
    215 : (? (uniq b @Z))       # Remember 'b'
    216  @Z=NIL                 # Succeeded
    217 
    218 : (? (uniq a @Z))       # Remembered 'a'?
    219 -> NIL                  # Yes: Not unique
    220 </code></pre>
    221 
    222 <dt><a name="unless"><code>(unless 'any . prg) -> any</code></a>
    223 <dd>Conditional execution: When the condition <code>any</code> evaluates to
    224 non-<code>NIL</code>, <code>NIL</code> is returned. Otherwise <code>prg</code>
    225 is executed and the result returned. See also <code><a
    226 href="refW.html#when">when</a></code>.
    227 
    228 <pre><code>
    229 : (unless (= 3 3) (println 'Strange 'result))
    230 -> NIL
    231 : (unless (= 3 4) (println 'Strange 'result))
    232 Strange result
    233 -> result
    234 </code></pre>
    235 
    236 <dt><a name="until"><code>(until 'any . prg) -> any</code></a>
    237 <dd>Conditional loop: While the condition <code>any</code> evaluates to
    238 <code>NIL</code>, <code>prg</code> is repeatedly executed. If <code>prg</code>
    239 is never executed, <code>NIL</code> is returned. Otherwise the result of
    240 <code>prg</code> is returned. See also <code><a
    241 href="refW.html#while">while</a></code>.
    242 
    243 <pre><code>
    244 : (until (=T (setq N (read)))
    245    (println 'square (* N N)) )
    246 4
    247 square 16
    248 9
    249 square 81
    250 T
    251 -> 81
    252 </code></pre>
    253 
    254 <dt><a name="untrace"><code>(untrace 'sym) -> sym</code></a>
    255 <dt><code>(untrace 'sym 'cls) -> sym</code>
    256 <dt><code>(untrace '(sym . cls)) -> sym</code>
    257 <dd>(Debug mode only) Removes the <code><a href="ref_.html#$">$</a></code> trace
    258 function call at the beginning of the function or method body of
    259 <code>sym</code>, so that no more trace information will be printed before and
    260 after execution. Built-in functions (C-function pointer) are automatically
    261 converted to their original form (see <code><a
    262 href="refS.html#subr">subr</a></code>). See also <code><a
    263 href="refT.html#trace">trace</a></code> and <code><a
    264 href="refT.html#traceAll">traceAll</a></code>.
    265 
    266 <pre><code>
    267 : (trace '+)                           # Trace the '+' function
    268 -> +
    269 : +
    270 -> (@ ($ + @ (pass $385455126)))       # Modified for tracing
    271 : (untrace '+)                         # Untrace '+'
    272 -> +
    273 : +
    274 -> 67319120                            # Back to original form
    275 </code></pre>
    276 
    277 <dt><a name="up"><code>(up [cnt] sym ['val]) -> any</code></a>
    278 <dd>Looks up (or modifies) the <code>cnt</code>'th previously saved value of
    279 <code>sym</code> in the corresponding enclosing environment. If <code>cnt</code>
    280 is not given, 1 is used. The 64-bit version also allows to omit the
    281 <code>sym</code> argument, then the corresponding expression (function or method
    282 call) is returned. See also <code><a href="refE.html#eval">eval</a></code>,
    283 <code><a href="refR.html#run">run</a></code>, <code><a
    284 href="refT.html#trail">trail</a></code> and <code><a
    285 href="refE.html#env">env</a></code>.
    286 
    287 <pre><code>
    288 : (let N 1 ((quote (N) (println N (up N))) 2))
    289 2 1
    290 -> 1
    291 : (let N 1 ((quote (N) (println N (up N) (up N 7))) 2) N)
    292 2 1 7
    293 -> 7
    294 
    295 : (de foo (N)
    296    (println (up))  # 64-bits only
    297    (inc N) )
    298 -> foo
    299 : (foo 7)
    300 (foo 7)
    301 -> 8
    302 </code></pre>
    303 
    304 <dt><a name="upd"><code>(upd sym ..) -> lst</code></a>
    305 <dd>Synchronizes the internal state of all passed (external) symbols by passing
    306 them to <code><a href="refW.html#wipe">wipe</a></code>. <code>upd</code> is the
    307 standard function passed to <code><a href="refC.html#commit">commit</a></code>
    308 during database <code><a href="ref.html#trans">transactions</a></code>.
    309 
    310 <pre><code>
    311 (commit 'upd)  # Commit changes, informing all sister processes
    312 </code></pre>
    313 
    314 <dt><a name="update"><code>(update 'obj ['var]) -> obj</code></a>
    315 <dd>(Debug mode only) Interactive database function for modifying external
    316 symbols. When called only with an <code>obj</code> argument, <code>update</code>
    317 steps through the value and all properties of that object (and recursively also
    318 through substructures) and allows to edit them with the console line editor.
    319 When the <code>var</code> argument is given, only that single property is handed
    320 to the editor. To delete a propery, <code>NIL</code> must be explicitly entered.
    321 <code>update</code> will correctly handle all <a
    322 href="ref.html#er">entity/relation</a> mechanisms. See also <code><a
    323 href="refS.html#select">select</a></code>, <code><a
    324 href="refE.html#edit">edit</a></code> and <a href="ref.html#dbase">Database</a>.
    325 
    326 <pre><code>
    327 : (show '{3-1})            # Show item 1
    328 {3-1} (+Item)
    329    nr 1
    330    pr 29900
    331    inv 100
    332    sup {2-1}
    333    nm "Main Part"
    334 -> {3-1}
    335 
    336 : (update '{3-1} 'pr)      # Update the prices of that item
    337 {3-1} pr 299.00            # The cursor is right behind "299.00"
    338 -> {3-1}
    339 </code></pre>
    340 
    341 <dt><a name="upp?"><code>(upp? 'any) -> sym | NIL</code></a> <dd>Returns
    342 <code>any</code> when the argument is a string (symbol) that starts with an
    343 uppercase character. See also <code><a href="refU.html#uppc">uppc</a></code> and
    344 <code><a href="refL.html#low?">low?</a></code>
    345 
    346 <pre><code>
    347 : (upp? "A")
    348 -> T
    349 : (upp? "a")
    350 -> NIL
    351 : (upp? 123)
    352 -> NIL
    353 : (upp? ".")
    354 -> NIL
    355 </code></pre>
    356 
    357 <dt><a name="uppc"><code>(uppc 'any) -> any</code></a>
    358 <dd>Upper case conversion: If <code>any</code> is not a symbol, it is returned
    359 as it is. Otherwise, a new transient symbol with all characters of
    360 <code>any</code>, converted to upper case, is returned. See also <code><a
    361 href="refL.html#lowc">lowc</a></code>, <code><a
    362 href="refF.html#fold">fold</a></code> and <code><a
    363 href="refU.html#upp?">upp?</a></code>.
    364 
    365 <pre><code>
    366 : (uppc 123)
    367 -> 123
    368 : (uppc "abc")
    369 -> "ABC"
    370 : (uppc 'car)
    371 -> "CAR"
    372 </code></pre>
    373 
    374 <dt><a name="use"><code>(use sym . prg) -> any</code></a>
    375 <dt><code>(use (sym ..) . prg) -> any</code>
    376 <dd>Defines local variables. The value of the symbol <code>sym</code> - or the
    377 values of the symbols <code>sym</code> in the list of the second form - are
    378 saved, <code>prg</code> is executed, then the symbols are restored to their
    379 original values. During execution of <code>prg</code>, the values of the symbols
    380 can be temporarily modified. The return value is the result of <code>prg</code>.
    381 See also <code><a href="refB.html#bind">bind</a></code>, <code><a
    382 href="refJ.html#job">job</a></code> and <code><a
    383 href="refL.html#let">let</a></code>.
    384 
    385 <pre><code>
    386 : (setq  X 123  Y 456)
    387 -> 456
    388 : (use (X Y) (setq  X 3  Y 4) (* X Y))
    389 -> 12
    390 : X
    391 -> 123
    392 : Y
    393 -> 456
    394 </code></pre>
    395 
    396 <dt><a name="useKey"><code>(useKey 'var 'cls ['hook]) -> num</code></a>
    397 <dd>Generates or reuses a key for a database tree, by randomly trying to locate
    398 a free number. See also <code><a href="refG.html#genKey">genKey</a></code>.
    399 
    400 <pre><code>
    401 : (maxKey (tree 'nr '+Item))
    402 -> 8
    403 : (useKey 'nr '+Item)
    404 -> 12
    405 </code></pre>
    406 
    407 <dt><a name="usec"><code>(usec ['flg]) -> num</code></a>
    408 <dd>Returns the number the microseconds. If <code>flg</code> is
    409 non-<code>NIL</code>, the microsecond fraction of the last call to <code><a
    410 href="refT.html#time">time</a></code> is returned, otherwise the number of
    411 microseconds since interpreter startup. See also <code><a
    412 href="refD.html#date">date</a></code> and <code><a
    413 href="refT.html#tick">tick</a></code>.
    414 
    415 <pre><code>
    416 : (usec)
    417 -> 1154702479219050
    418 : (list (date (date)) (time (time T)) (usec T))
    419 -> ((2013 1 4) (10 12 39) 483321)
    420 </code></pre>
    421 
    422 </dl>
    423 
    424 </body>
    425 </html>