picolisp

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

refW.html (6230B)


      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>W</title>
      6 <link rel="stylesheet" href="doc.css" type="text/css">
      7 </head>
      8 <body>
      9 
     10 <h1>W</h1>
     11 
     12 <dl>
     13 
     14 <dt><a name="wait"><code>(wait ['cnt] . prg) -> any</code></a>
     15 <dd>Waits for a condition. While the result of the execution of <code>prg</code>
     16 is <code>NIL</code>, a <code>select</code> system call is executed for all file
     17 descriptors and timers in the <code>VAL</code> of the global variable <code><a
     18 href="refR.html#*Run">*Run</a></code>. When <code>cnt</code> is
     19 non-<code>NIL</code>, the waiting time is limited to <code>cnt</code>
     20 milliseconds. Returns the result of <code>prg</code>. See also <code><a
     21 href="refK.html#key">key</a></code> and <code><a
     22 href="refS.html#sync">sync</a></code>.
     23 
     24 <pre><code>
     25 : (wait 2000)                                # Wait 2 seconds
     26 -> NIL
     27 : (prog
     28    (zero *Cnt)
     29    (setq *Run                                # Install background loop
     30       '((-2000 0 (println (inc '*Cnt)))) )   # Increment '*Cnt' every 2 sec
     31    (wait NIL (> *Cnt 6))                     # Wait until > 6
     32    (off *Run) )
     33 1                                            # Waiting ..
     34 2
     35 3
     36 4
     37 5
     38 6
     39 7
     40 -> NIL
     41 </code></pre>
     42 
     43 <dt><a name="week"><code>(week 'dat) -> num</code></a>
     44 <dd>Returns the number of the week for a given <code><a
     45 href="refD.html#date">date</a></code> <code>dat</code>. See also <code><a
     46 href="refD.html#day">day</a></code>, <code><a
     47 href="refU.html#ultimo">ultimo</a></code>, <code><a
     48 href="refD.html#datStr">datStr</a></code> and <code><a
     49 href="refS.html#strDat">strDat</a></code>.
     50 
     51 <pre><code>
     52 : (datStr (date))
     53 -> "2007-06-01"
     54 : (week (date))
     55 -> 22
     56 </code></pre>
     57 
     58 <dt><a name="when"><code>(when 'any . prg) -> any</code></a>
     59 <dd>Conditional execution: When the condition <code>any</code> evaluates to
     60 non-<code>NIL</code>, <code>prg</code> is executed and the result is returned.
     61 Otherwise <code>NIL</code> is returned. See also <code><a
     62 href="refU.html#unless">unless</a></code>.
     63 
     64 <pre><code>
     65 : (when (> 4 3) (println 'OK) (println 'Good))
     66 OK
     67 Good
     68 -> Good
     69 </code></pre>
     70 
     71 <dt><a name="while"><code>(while 'any . prg) -> any</code></a>
     72 <dd>Conditional loop: While the condition <code>any</code> evaluates to
     73 non-<code>NIL</code>, <code>prg</code> is repeatedly executed. If
     74 <code>prg</code> is never executed, <code>NIL</code> is returned. Otherwise the
     75 result of <code>prg</code> is returned. See also <code><a
     76 href="refU.html#until">until</a></code>.
     77 
     78 <pre><code>
     79 : (while (read)
     80    (println 'got: @) )
     81 abc
     82 got: abc
     83 1234
     84 got: 1234
     85 NIL
     86 -> 1234
     87 </code></pre>
     88 
     89 <dt><a name="what"><code>(what 'sym) -> lst</code></a>
     90 <dd>(Debug mode only) Returns a list of all internal symbols that match the
     91 pattern string <code>sym</code>. See also <code><a
     92 href="refM.html#match">match</a></code>, <code><a
     93 href="refW.html#who">who</a></code> and <code><a
     94 href="refC.html#can">can</a></code>.
     95 
     96 <pre><code>
     97 : (what "cd@dr")
     98 -> (cdaddr cdaadr cddr cddddr cdddr cddadr cdadr)
     99 </code></pre>
    100 
    101 <dt><a name="who"><code>(who 'any) -> lst</code></a>
    102 <dd>(Debug mode only) Returns a list of all functions or method definitions that
    103 contain the atom or pattern <code>any</code>. See also <code><a
    104 href="refM.html#match">match</a></code>, <code><a
    105 href="refW.html#what">what</a></code> and <code><a
    106 href="refC.html#can">can</a></code>.
    107 
    108 <pre><code>
    109 : (who 'caddr)                         # Who is using 'caddr'?
    110 -> ($dat lint1 expDat datStr $tim tim$ mail _gen dat$ datSym)
    111 
    112 : (who "Type error")
    113 -> ((mis> . +Link) *Uni (mis> . +Joint))
    114 
    115 : (more (who "Type error") pp)         # Pretty print all results
    116 (dm (mis> . +Link) (Val Obj)
    117    (and
    118       Val
    119       (nor (isa (: type) Val) (canQuery Val))
    120       "Type error" ) )
    121 .                                      # Stop
    122 -> T
    123 </code></pre>
    124 
    125 <dt><a name="wipe"><code>(wipe 'sym|lst) -> sym|lst</code></a>
    126 <dd>Clears the <code>VAL</code> and the property list of <code>sym</code>, or of
    127 all symbols in the list <code>lst</code>. When a symbol is an external symbol,
    128 its state is also set to "not loaded". Does nothing when <code>sym</code> is an
    129 external symbol that has been modified or deleted ("dirty").
    130 
    131 <pre><code>
    132 : (setq A (1 2 3 4))
    133 -> (1 2 3 4)
    134 : (put 'A 'a 1)
    135 -> 1
    136 : (put 'A 'b 2)
    137 -> 2
    138 : (show 'A)
    139 A (1 2 3 4)
    140    b 2
    141    a 1
    142 -> A
    143 : (wipe 'A)
    144 -> A
    145 : (show 'A)
    146 A NIL
    147 -> A
    148 </code></pre>
    149 
    150 <dt><a name="with"><code>(with 'sym . prg) -> any</code></a>
    151 <dd>Saves the current object <code>This</code> and sets it to the new value
    152 <code>sym</code>. Then <code>prg</code> is executed, and <code>This</code> is
    153 restored to its previous value. The return value is the result of
    154 <code>prg</code>. Used typically to access the local data of <code>sym</code> in
    155 the same manner as inside a method body. <code>prg</code> is not executed (and
    156 <code>NIL</code> is returned) when <code>sym</code> is <code>NIL</code>.
    157 <code>(with 'X . prg)</code> is equivalent to <code>(let? This 'X . prg)</code>.
    158 
    159 <pre><code>
    160 : (put 'X 'a 1)
    161 -> 1
    162 : (put 'X 'b 2)
    163 -> 2
    164 : (with 'X (list (: a) (: b)))
    165 -> (1 2)
    166 </code></pre>
    167 
    168 <dt><a name="wr"><code>(wr 'cnt ..) -> cnt</code></a>
    169 <dd>Writes all <code>cnt</code> arguments as raw bytes to the current output
    170 channel. See also <code><a href="refR.html#rd">rd</a></code> and <code><a
    171 href="refP.html#pr">pr</a></code>.
    172 
    173 <pre><code>
    174 : (out "x" (wr 1 255 257))  # Write to "x"
    175 -> 257
    176 : (hd "x")
    177 00000000  01 FF 01                                         ...
    178 -> NIL
    179 </code></pre>
    180 
    181 <dt><a name="wrap"><code>(wrap 'cnt 'lst) -> sym</code></a>
    182 <dd>Returns a transient symbol with all characters in <code>lst</code> <code><a
    183 href="refP.html#pack">pack</a></code>ed in lines with a maximal length of
    184 <code>cnt</code>. See also <code><a href="refT.html#tab">tab</a></code>,
    185 <code><a href="refA.html#align">align</a></code> and <code><a
    186 href="refC.html#center">center</a></code>.
    187 
    188 <pre><code>
    189 : (wrap 20 (chop "The quick brown fox jumps over the lazy dog"))
    190 -> "The quick brown fox^Jjumps over the lazy^Jdog"
    191 : (wrap 8 (chop "The quick brown fox jumps over the lazy dog"))
    192 -> "The^Jquick^Jbrown^Jfox^Jjumps^Jover the^Jlazy dog"
    193 </code></pre>
    194 
    195 </dl>
    196 
    197 </body>
    198 </html>