picolisp

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

refO.html (8927B)


      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>O</title>
      6 <link rel="stylesheet" href="doc.css" type="text/css">
      7 </head>
      8 <body>
      9 
     10 <h1>O</h1>
     11 
     12 <dl>
     13 
     14 <dt><a name="*Once"><code>*Once</code></a>
     15 <dd>Holds an <code><a href="refI.html#idx">idx</a></code> tree of already
     16 <code><a href="refL.html#load">load</a></code>ed source locations (as returned
     17 by <code><a href="refF.html#file">file</a></code>) See also <code><a
     18 href="refO.html#once">once</a></code>.
     19 
     20 <pre><code>
     21 : *Once
     22 -> (("lib/" "misc.l" . 11) (("lib/" "http.l" . 9) (("lib/" "form.l" . 11))))
     23 </code></pre>
     24 
     25 <dt><a name="*OS"><code>*OS</code></a>
     26 <dd>A global constant holding the name of the operating system. Possible values
     27 include <code>"Linux"</code>, <code>"FreeBSD"</code>, <code>"Darwin"</code> or
     28 <code>"Cygwin"</code>. See also <code><a href="refC.html#*CPU">*CPU</a></code>.
     29 
     30 <pre><code>
     31 : *OS
     32 -> "Linux"
     33 </code></pre>
     34 
     35 <dt><a name="obj"><code>(obj (typ var [hook] val ..) var2 val2 ..) -> obj</code></a>
     36 <dd>Finds or creates a database object (using <code><a
     37 href="refR.html#request">request</a></code>) corresponding to <code>(typ var
     38 [hook] val ..)</code>, and initializes additional properties using the
     39 <code>varN</code> and <code>valN</code> arguments.
     40 
     41 <pre><code>
     42 : (obj ((+Item) nr 2) nm "Spare Part" sup `(db 'nr '+CuSu 2) inv 100 pr 1250)
     43 -> {3-2}
     44 </code></pre>
     45 
     46 <dt><a name="object"><code>(object 'sym 'any ['sym2 'any2 ..]) -> obj</code></a>
     47 <dd>Defines <code>sym</code> to be an object with the value (or type)
     48 <code>any</code>. The property list is initialized with all optionally supplied
     49 key-value pairs. See also <a href="ref.html#oop">OO Concepts</a>, <code><a
     50 href="refN.html#new">new</a></code>, <code><a
     51 href="refT.html#type">type</a></code> and <code><a
     52 href="refI.html#isa">isa</a></code>.
     53 
     54 <pre><code>
     55 : (object 'Obj '(+A +B +C) 'a 1 'b 2 'c 3)
     56 -> Obj
     57 : (show 'Obj)
     58 Obj (+A +B +C)
     59    c 3
     60    b 2
     61    a 1
     62 -> Obj
     63 </code></pre>
     64 
     65 <dt><a name="oct"><code>(oct 'num ['num]) -> sym</code></a>
     66 <dt><code>(oct 'sym) -> num</code>
     67 <dd>Converts a number <code>num</code> to an octal string, or an octal string
     68 <code>sym</code> to a number. In the first case, if the second argument is
     69 given, the result is separated by spaces into groups of such many digits. See
     70 also <code><a href="refB.html#bin">bin</a></code>, <code><a
     71 href="refH.html#hex">hex</a></code>, <code><a
     72 href="refF.html#fmt64">fmt64</a></code>, <code><a
     73 href="refH.html#hax">hax</a></code> and <code><a
     74 href="refF.html#format">format</a></code>.
     75 
     76 <pre><code>
     77 : (oct 73)
     78 -> "111"
     79 : (oct "111")
     80 -> 73
     81 : (oct 1234567 3)
     82 -> "4 553 207"
     83 </code></pre>
     84 
     85 <dt><a name="off"><code>(off var ..) -> NIL</code></a>
     86 <dd>Stores <code>NIL</code> in all <code>var</code> arguments. See also <code><a
     87 href="refO.html#on">on</a></code>, <code><a
     88 href="refO.html#onOff">onOff</a></code>, <code><a
     89 href="refZ.html#zero">zero</a></code> and <code><a
     90 href="refO.html#one">one</a></code>.
     91 
     92 <pre><code>
     93 : (off A B)
     94 -> NIL
     95 : A
     96 -> NIL
     97 : B
     98 -> NIL
     99 </code></pre>
    100 
    101 <dt><a name="offset"><code>(offset 'lst1 'lst2) -> cnt | NIL</code></a>
    102 <dd>Returns the <code>cnt</code> position of the tail list <code>lst1</code> in
    103 <code>lst2</code>, or <code>NIL</code> if it is not found. See also <code><a
    104 href="refI.html#index">index</a></code> and <code><a
    105 href="refT.html#tail">tail</a></code>.
    106 
    107 <pre><code>
    108 : (offset '(c d e f) '(a b c d e f))
    109 -> 3
    110 : (offset '(c d e) '(a b c d e f))
    111 -> NIL
    112 </code></pre>
    113 
    114 <dt><a name="on"><code>(on var ..) -> T</code></a>
    115 <dd>Stores <code>T</code> in all <code>var</code> arguments. See also <code><a
    116 href="refO.html#off">off</a></code>, <code><a
    117 href="refO.html#onOff">onOff</a></code>, <code><a
    118 href="refZ.html#zero">zero</a></code> and <code><a
    119 href="refO.html#one">one</a></code>.
    120 
    121 <pre><code>
    122 : (on A B)
    123 -> T
    124 : A
    125 -> T
    126 : B
    127 -> T
    128 </code></pre>
    129 
    130 <dt><a name="once"><code>(once . prg) -> any</code></a>
    131 <dd>Executes <code>prg</code> once, when the current file is <code><a
    132 href="refL.html#load">load</a></code>ed the first time. Subsequent loads at a
    133 later time will not execute <code>prg</code>, and <code>once</code> returns
    134 <code>NIL</code>. See also <code><a href="refO.html#*Once">*Once</a></code>.
    135 
    136 <pre><code>
    137 (once
    138    (zero *Cnt1 *Cnt2)  # Init counters
    139    (load "file1.l" "file2.l") )  # Load other files
    140 </code></pre>
    141 
    142 <dt><a name="one"><code>(one var ..) -> 1</code></a>
    143 <dd>Stores <code>1</code> in all <code>var</code> arguments. See also <code><a
    144 href="refZ.html#zero">zero</a></code>, <code><a
    145 href="refO.html#on">on</a></code>, <code><a href="refO.html#off">off</a></code>
    146 and <code><a href="refO.html#onOff">onOff</a></code>.
    147 
    148 <pre><code>
    149 : (one A B)
    150 -> 1
    151 : A
    152 -> 1
    153 : B
    154 -> 1
    155 </code></pre>
    156 
    157 <dt><a name="onOff"><code>(onOff var ..) -> flg</code></a>
    158 <dd>Logically negates the values of all <code>var</code> arguments. Returns the
    159 new value of the last symbol. See also <code><a
    160 href="refO.html#on">on</a></code>, <code><a href="refO.html#off">off</a></code>,
    161 <code><a href="refZ.html#zero">zero</a></code> and <code><a
    162 href="refO.html#one">one</a></code>.
    163 
    164 <pre><code>
    165 : (onOff A B)
    166 -> T
    167 : A
    168 -> T
    169 : B
    170 -> T
    171 : (onOff A B)
    172 -> NIL
    173 : A
    174 -> NIL
    175 : B
    176 -> NIL
    177 </code></pre>
    178 
    179 <dt><a name="open"><code>(open 'any ['flg]) -> cnt | NIL</code></a>
    180 <dd>Opens the file with the name <code>any</code> in read/write mode (or
    181 read-only if <code>flg</code> is non-<code>NIL</code>), and returns a file
    182 descriptor <code>cnt</code> (or <code>NIL</code> on error). A leading
    183 "<code>@</code>" character in <code>any</code> is substituted with the
    184 <u>PicoLisp Home Directory</u>, as it was remembered during interpreter startup.
    185 If <code>flg</code> is <code>NIL</code> and the file does not exist, it is
    186 created. The file descriptor can be used in subsequent calls to <code><a
    187 href="refI.html#in">in</a></code> and <code><a
    188 href="refO.html#out">out</a></code>. See also <code><a
    189 href="refC.html#close">close</a></code> and <code><a
    190 href="refP.html#poll">poll</a></code>.
    191 
    192 <pre><code>
    193 : (open "x")
    194 -> 3
    195 </code></pre>
    196 
    197 <dt><a name="opid"><code>(opid) -> pid | NIL</code></a>
    198 <dd>Returns the corresponding process ID when the current output channel is
    199 writing to a pipe, otherwise <code>NIL</code>. See also <code><a
    200 href="refI.html#ipid">ipid</a></code> and <code><a
    201 href="refO.html#out">out</a></code>.
    202 
    203 <pre><code>
    204 : (out '(cat) (call 'ps "-p" (opid)))
    205   PID TTY          TIME CMD
    206  7127 pts/3    00:00:00 cat
    207 -> T
    208 </code></pre>
    209 
    210 <dt><a name="opt"><code>(opt) -> sym</code></a>
    211 <dd>Return the next command line argument ("option", as would be processed by
    212 <code><a href="refL.html#load">load</a></code>) as a string, and remove it from
    213 the remaining command line arguments. See also <a
    214 href="ref.html#invoc">Invocation</a> and <code><a
    215 href="refA.html#argv">argv</a></code>.
    216 
    217 <pre><code>
    218 $ pil  -"de f () (println 'opt (opt))"  -f abc  -bye
    219 opt "abc"
    220 </code></pre>
    221 
    222 <dt><a name="or"><code>(or 'any ..) -> any</code></a>
    223 <dd>Logical OR. The expressions <code>any</code> are evaluated from left to
    224 right. If a non-<code>NIL</code> value is encountered, it is returned
    225 immediately. Else the result of the last expression is returned.
    226 
    227 <pre><code>
    228 : (or (= 3 3) (read))
    229 -> T
    230 : (or (= 3 4) (read))
    231 abc
    232 -> abc
    233 </code></pre>
    234 
    235 <dt><a name="or/2"><code>or/2</code></a>
    236 <dd><a href="ref.html#pilog">Pilog</a> predicate that takes an arbitrary number
    237 of clauses, and succeeds if one of them can be proven. See also <code><a
    238 href="refN.html#not/1">not/1</a></code>.
    239 
    240 <pre><code>
    241 : (?
    242    (or
    243       ((equal 3 @X) (equal @X 4))
    244       ((equal 7 @X) (equal @X 7)) ) )
    245  @X=7
    246 -> NIL</code></pre>
    247 
    248 <dt><a name="out"><code>(out 'any . prg) -> any</code></a>
    249 <dd>Opens <code>any</code> as output channel during the execution of
    250 <code>prg</code>. The current output channel will be saved and restored
    251 appropriately. If the argument is <code>NIL</code>, standard output is used. If
    252 the argument is a symbol, it is used as a file name (opened in "append" mode if
    253 the first character is "<code>+</code>"). If it is a positve number, it is used
    254 as the descriptor of an open file. If it is a negative number, the saved output
    255 channel such many levels above the current one is used. Otherwise (if it is a
    256 list), it is taken as a command with arguments, and a pipe is opened for output.
    257 See also <code><a href="refO.html#opid">opid</a></code>, <code> <a
    258 href="refC.html#call">call</a></code>, <code><a
    259 href="refI.html#in">in</a></code>, <code> <a
    260 href="refE.html#err">err</a></code>, <code> <a
    261 href="refC.html#ctl">ctl</a></code>, <code><a
    262 href="refP.html#pipe">pipe</a></code>, <code> <a
    263 href="refP.html#poll">poll</a></code>, <code> <a
    264 href="refC.html#close">close</a></code> and <code><a
    265 href="refL.html#load">load</a></code>.
    266 
    267 <pre><code>
    268 : (out "a" (println 123 '(a b c) 'def))  # Write one line to file "a"
    269 -> def
    270 </code></pre>
    271 
    272 </dl>
    273 
    274 </body>
    275 </html>