📄 refc.html
字号:
<code>any</code> is <code>NIL</code> or a symbol with no name, <code>NIL</code>is returned. A list argument is returned unchanged.<p><pre><code>: (chop 'car)-> ("c" "a" "r"): (chop "Hello")-> ("H" "e" "l" "l" "o")</code></pre><dt><a name="circ"><code>(circ 'any ..) -> lst</code></a><dd>Produces a circular list of all <code>any</code> arguments by <code><ahref="refC.html#cons">cons</a></code>ing them to a list and then connecting the<code>CDR</code> of the last cell to the first cell. See also <code><ahref="refL.html#list">list</a></code>.<p><pre><code>: (circ 'a 'b 'c)-> (a b c .)</code></pre><dt><a name="class"><code>(class sym . typ) -> obj</code></a><dd>Defines <code>sym</code> as a class with the superclass(es)<code>typ</code>. As a side effect, the global variable <code><ahref="refC.html#*Class">*Class</a></code> is set to <code>obj</code>. See also<code><a href="refE.html#extend">extend</a></code>, <code><ahref="refD.html#dm">dm</a></code>, <code><a href="refV.html#var">var</a></code>,<code><a href="refR.html#rel">rel</a></code>, <code><ahref="refT.html#type">type</a></code>, <code><ahref="refI.html#isa">isa</a></code> and <code><ahref="refO.html#object">object</a></code>.<p><pre><code>: (class +A +B +C +D)-> +A: +A-> (+B +C +D): (dm foo> (X) (bar X))-> foo>: +A-> ((foo> (X) (bar X)) +B +C +D)</code></pre><dt><a name="clip"><code>(clip 'lst) -> lst</code></a><dd>Returns a copy of <code>lst</code> with all white space characters or<code>NIL</code> elements removed from both sides. See also <code><ahref="refT.html#trim">trim</a></code>.<p><pre><code>: (clip '(NIL 1 NIL 2 NIL))-> (1 NIL 2): (clip '(" " a " " b " "))-> (a " " b)</code></pre><dt><a name="close"><code>(close 'cnt) -> cnt | NIL</code></a><dd>Closes a file descriptor <code>cnt</code>, and returns it when successful.Should not be called inside an <code><a href="refO.html#out">out</a></code> bodyfor that descriptor. See also <code><a href="refO.html#open">open</a></code>,<code><a href="refL.html#listen">listen</a></code> and <code><ahref="refC.html#connect">connect</a></code>.<p><pre><code>: (close 2) # Close standard error-> 2</code></pre><dt><a name="cnt"><code>(cnt 'fun 'lst ..) -> cnt</code></a><dd>Applies <code>fun</code> to each element of <code>lst</code>. Whenadditional <code>lst</code> arguments are given, their elements are also passedto <code>fun</code>. Returns the count of non-<code>NIL</code> values returnedfrom <code>fun</code>.<p><pre><code>: (cnt cdr '((1 . T) (2) (3 4) (5)))-> 2</code></pre><dt><a name="collect"><code>(collect 'var 'cls ['hook] ['any|beg ['end [var ..]]])</code></a><dd>Returns a list of all database objects of class <code>cls</code>, where thevalues for the <code>var</code> arguments correspond to the <code>any</code>arguments, or where the values for the <code>var</code> arguments are in therange <code>beg</code> .. <code>end</code>. <code>var</code>, <code>cls</code>and <code>hook</code> should specify a <code><ahref="refT.html#tree">tree</a></code> for <code>cls</code> or one of itssuperclasses. If additional <code>var</code> arguments are given, the finalvalues for the result list are obtained by applying the <code><ahref="refG.html#get">get</a></code> algorithm. See also <code><ahref="refD.html#db">db</a></code>, <code><a href="refA.html#aux">aux</a></code>,<code><a href="refF.html#fetch">fetch</a></code>, <code><ahref="refI.html#init">init</a></code> and <code><ahref="refS.html#step">step</a></code>.<p><pre><code>: (collect 'nr '+Item)-> ({3-1} {3-2} {3-3} {3-4} {3-5} {3-6} {3-8}): (collect 'nr '+Item 3 6 'nr)-> (3 4 5 6): (collect 'nr '+Item 3 6 'nm)-> ("Auxiliary Construction" "Enhancement Additive" "Metal Fittings" "Gadget Appliance"): (collect 'nm '+Item "Main Part")-> ({3-1})</code></pre><dt><a name="commit"><code>(commit ['any] [exe1] [exe2]) -> flg</code></a><dd>Closes a transaction, by writing all new or modified external symbols to thedatabase, and by removing all deleted symbols from the database. For nestedtransactions, only the changes since the last call to <code><ahref="refB.html#begin">begin</a></code> are taken into account. Anon-<code>NIL</code> <code>any</code> argument forces modifications of thecurrent transaction level to be written out, even if this is not the top level.When <code>any</code> is anything other than <code>T</code>, it is implicitlysent (with all modified objects) via the <code><ahref="refT.html#tell">tell</a></code> mechanism to all family members. If<code>exe1</code> or <code>exe2</code> are given, they are executed as pre- orpost-expressions while the database is <code><ahref="refL.html#lock">lock</a></code>ed and <code><ahref="refP.html#protect">protect</a></code>ed. Returns <code>T</code> when thetopmost transaction is closed. See also <code><ahref="refR.html#rollback">rollback</a></code>.<p><pre><code>: (pool "db")-> T: (put '{1} 'str "Hello")-> "Hello": (commit)-> T</code></pre><dt><a name="con"><code>(con 'lst 'any) -> any</code></a><dd>Connects <code>any</code> to the first cell of <code>lst</code>, by(destructively) storing <code>any</code> in the <code>CDR</code> of<code>lst</code>.<p><pre><code>: (setq C (1 . a))-> (1 . a): (con C '(b c d))-> (b c d): C-> (1 b c d)</code></pre><dt><a name="conc"><code>(conc 'lst ..) -> lst</code></a><dd>Concatenates all argument lists (destructively). See also <code><ahref="refA.html#append">append</a></code>.<p><pre><code>: (setq A (1 2 3) B '(a b c))-> (a b c): (conc A B) # Concatenate lists in 'A' and 'B'-> (1 2 3 a b c): A-> (1 2 3 a b c) # Side effect: List in 'A' is modified!</code></pre><dt><a name="cond"><code>(cond ('any1 . prg1) ('any2 . prg2) ..) -> any</code></a><dd>Multi-way conditional: If any of the <code>anyN</code> conditions evaluatesto non-<code>NIL</code>, <code>prgN</code> is executed and the result returned.Otherwise (all conditions evaluate to <code>NIL</code>), <code>NIL</code> isreturned. See also <code><a href="refN.html#nond">nond</a></code>, <code><ahref="refI.html#if">if</a></code>, <code><a href="refI.html#if2">if2</a></code>and <code><a href="refW.html#when">when</a></code>.<p><pre><code>: (cond ((= 3 4) (println 1)) ((= 3 3) (println 2)) (T (println 3)) )2-> 2</code></pre><dt><a name="connect"><code>(connect 'any 'cnt) -> cnt | NIL</code></a><dd>Tries to establish a TCP/IP connection to a server listening at host<code>any</code>, port <code>cnt</code>. <code>any</code> may be either ahostname or a standard internet address in numbers-and-dots notation. Returns asocket descriptor <code>cnt</code>, or <code>NIL</code> if the connection cannotbe established. See also <code><a href="refL.html#listen">listen</a></code> and<code><a href="refN.html#nagle">nagle</a></code>.<p><pre><code>: (connect "localhost" 4444)-> 3</code></pre><dt><a name="cons"><code>(cons 'any ['any ..]) -> lst</code></a><dd>Constructs a new list cell with the first argument in the <code>CAR</code>and the second argument in the <code>CDR</code>. If more than two arguments aregiven, a corresponding chain of cells is built. <code>(cons 'a 'b 'c 'd)</code>is equivalent to <code>(cons 'a (cons 'b (cons 'c 'd)))</code>.<p><pre><code>: (cons 1 2)-> (1 . 2): (cons 'a '(b c d))-> (a b c d): (cons '(a b) '(c d))-> ((a b) c d): (cons 'a 'b 'c 'd)-> (a b c . d)</code></pre><dt><a name="copy"><code>(copy 'any) -> any</code></a><dd>Copies the argument <code>any</code>. For lists, the top level cells arecopied, while atoms are returned unchanged.<p><pre><code>: (=T (copy T)) # Atoms are not copied-> T: (setq L (1 2 3))-> (1 2 3): (== L L)-> T: (== L (copy L)) # The copy is not identical to the original-> NIL: (= L (copy L)) # But the copy is equal to the original-> T</code></pre><dt><a name="count"><code>(count 'tree) -> num</code></a><dd>Returns the number of nodes in a database tree. See also <code><ahref="refT.html#tree">tree</a></code> and <code><ahref="refR.html#root">root</a></code>.<p><pre><code>: (count (tree 'nr '+Item))-> 7</code></pre><dt><a name="ctl"><code>(ctl 'sym . prg) -> any</code></a><dd>Waits until a write (exclusive) lock (or a read (shared) lock if the firstcharacter of <code>sym</code> is "<code>+</code>") can be set on the file<code>sym</code>, then executes <code>prg</code> and releases the lock. If thefiles does not exist, it will be created. When <code>sym</code> is<code>NIL</code>, a shared lock is tried on the current innermost I/O channel,and when it is <code>T</code>, an exclusive lock is tried instead. See also<code><a href="refI.html#in">in</a></code>, <code><ahref="refP.html#pipe">pipe</a></code> and <code><ahref="refO.html#out">out</a></code>. Note: It is not recommended to lock a fileby name and then do I/O on the same file, as this may give unexpected results onsome operating systems.<p><pre><code>$ echo 9 >count # Write '9' to file "count"$ ./p dbg.l: (ctl ".ctl" # Exclusive control, using ".ctl" (in "count" (let Cnt (read) # Read '9' (out "count" (println (dec Cnt)) ) ) ) ) # Write '8'-> 8:$ cat count # Check "count"8</code></pre><dt><a name="ctty"><code>(ctty 'sym|pid) -> flg</code></a><dd>When called with a symbolic argument, <code>ctty</code> changes the currentTTY device to <code>sym</code>. Otherwise, the local console is prepared forserving the remote Pico Lisp process <code>pid</code>. See also <code><ahref="refR.html#raw">raw</a></code>.<p><pre><code>: (ctty "/dev/tty")-> T</code></pre><dt><a name="curry"><code>(curry lst . fun) -> fun</code></a><dd>Builds a new function from the list of symbols <code>lst</code> and thefunctional expression <code>fun</code>. Each member in <code>lst</code> that isa <code><a href="refP.html#pat?">pat?</a></code> symbol is immediatelysubstituted inside <code>fun</code> by its value. All other symbols in<code>lst</code> are collected into a <code><ahref="refJ.html#job">job</a></code> environment.<p><pre><code>: (de multiplier (@X) (curry (@X) (N) (* @X N)) )-> multiplier: (multiplier 7)-> ((N) (* 7 N)): ((multiplier 7) 3))-> 21: (let (N1 0 N2 1) (def 'fiboCounter (curry (N1 N2) (Cnt) (do Cnt (println (prog1 (+ N1 N2) (setq N1 N2 N2 @) ) ) ) ) ) )-> fiboCounter: (pp 'fiboCounter)(de fiboCounter (Cnt) (job '((N2 . 1) (N1 . 0)) (do Cnt (println (prog1 (+ N1 N2) (setq N1 N2 N2 @)) ) ) ) )-> fiboCounter: (fiboCounter 5)12358-> 8: (fiboCounter 5)1321345589-> 89</code></pre><dt><a name="cut"><code>(cut 'cnt 'var) -> lst</code></a><dd>Pops the first <code>cnt</code> elements (<code>CAR</code>) from the stackin <code>var</code>. See also <code><a href="refP.html#pop">pop</a></code> and<code><a href="refD.html#del">del</a></code>.<p><pre><code>: (setq S '(1 2 3 4 5 6 7 8))-> (1 2 3 4 5 6 7 8): (cut 3 'S)-> (1 2 3): S-> (4 5 6 7 8)</code></pre></dl></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -