📄 refp.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>P</title><link rel="stylesheet" href="doc.css" type="text/css"></head><body><h1>P</h1><dl><dt><a name="*PPid"><code>*PPid</code></a><dd>A global constant holding the process-id of the parent picolisp process, or<code>NIL</code> if the current process is a top level process.<p><pre><code>: (println *PPid *Pid)NIL 5286: (unless (fork) (println *PPid *Pid) (bye))5286 5522</code></pre><dt><a name="*Pid"><code>*Pid</code></a><dd>A global constant holding the current process-id.<p><pre><code>: *Pid-> 6386: (call "ps") # Show processes PID TTY TIME CMD .... ... ........ ..... 6386 pts/1 00:00:00 bin/picolisp # <- current process 6388 pts/1 00:00:00 ps-> T</code></pre><dt><a name="pack"><code>(pack 'any ..) -> sym</code></a><dd>Returns a transient symbol whose name is concatenated from all arguments<code>any</code>. A <code>NIL</code> arguments contributes nothing to the resultstring, a number is converted to a digit string, a symbol supplies thecharacters of its name, and for a list its elements are taken. See also <code><ahref="refT.html#text">text</a></code> and <code><ahref="refG.html#glue">glue</a></code>.<p><pre><code>: (pack 'car " is " 1 '(" symbol " name))-> "car is 1 symbol name"</code></pre><dt><a name="pad"><code>(pad 'cnt 'num) -> sym</code></a><dd>Returns a transient symbol with <code>num</code> <code><ahref="refP.html#pack">pack</a></code>ed with leading '0' characters, up to afield width of <code>cnt</code>. See also <code><ahref="refF.html#format">format</a></code> and <code><ahref="refA.html#align">align</a></code>.<p><pre><code>: (pad 5 1)-> "00001": (pad 5 123456789)-> "123456789"</code></pre><dt><a name="pair"><code>(pair 'any) -> any</code></a><dd>Returns <code>any</code> when the argument a cons pair cell. See also<code><a href="refA.html#atom">atom</a></code>.<p><pre><code>: (pair NIL)-> NIL: (pair (1 . 2))-> (1 . 2): (pair (1 2 3))-> (1 2 3)</code></pre><dt><a name="pass"><code>(pass 'fun ['any ..]) -> any</code></a><dd>Passes to <code>fun</code> all arguments <code>any</code>, and all remainingvariable arguments (<code>@</code>) as they would be returned by <code><ahref="refR.html#rest">rest</a></code>. <code>(pass 'fun 'any)</code> isequivalent to <code>(apply 'fun (rest) 'any)</code>. See also <code><ahref="refA.html#apply">apply</a></code>.<p><pre><code>: (de bar (A B . @) (println 'bar A B (rest)) )-> bar: (de foo (A B . @) (println 'foo A B) (pass bar 1) (pass bar 2) )-> foo: (foo 'a 'b 'c 'd 'e 'f)foo a bbar 1 c (d e f)bar 2 c (d e f)-> (d e f)</code></pre><dt><a name="pat?"><code>(pat? 'any) -> sym | NIL</code></a><dd>Returns <code>any</code> when the argument <code>any</code> is a symbolwhose name starts with an at-mark "<code>@</code>", otherwise <code>NIL</code>.<p><pre><code>: (pat? '@)-> @: (pat? "@Abc")-> "@Abc": (pat? "ABC")-> NIL: (pat? 123)-> NIL</code></pre><dt><a name="patch"><code>(patch 'lst 'pat . prg) -> any</code></a><dd>Destructively replaces all sub-expressions of <code>lst</code>, that<code><a href="refM.html#match">match</a></code> the pattern <code>pat</code>,by the result of the execution of <code>prg</code>. See also <code><ahref="refD.html#daemon">daemon</a></code> and <code><ahref="refR.html#redef">redef</a></code>.<p><pre><code>: (pp 'hello)(de hello NIL (prinl "Hello world!") )-> hello: (patch hello 'prinl 'println)-> NIL: (pp 'hello)(de hello NIL (println "Hello world!") )-> hello: (patch hello '(prinl @S) (fill '(println "We said: " . @S)))-> NIL: (hello)We said: Hello world!-> "Hello world!"</code></pre><dt><a name="path"><code>(path 'sym) -> sym</code></a><dd>Substitutes any leading "<code>@</code>" character in the <code>sym</code>argument with the <u>Pico Lisp Home Directory</u>, as it was remembered duringinterpreter startup. Optionally, the name may be preceded by a "<code>+</code>"character (as used by <code><a href="refO.html#out">out</a></code>). Thismechanism is used internally by all I/O functions. See also <code><ahref="ref.html#invoc">Invocation</a></code> and <code><ahref="refD.html#dirname">dirname</a></code>.<p><pre><code>$ /usr/bin/picolisp /usr/lib/picolisp/lib.l: (path "a/b/c")-> "a/b/c": (path "@a/b/c")-> "/usr/lib/picolisp/a/b/c": (path "+@a/b/c")-> "+/usr/lib/picolisp/a/b/c"</code></pre><dt><a name="peek"><code>(peek) -> sym</code></a><dd>Single character look-ahead: Returns the same character as the next call to<code><a href="refC.html#char">char</a></code> would return. See also <code><ahref="refS.html#skip">skip</a></code>.<p><pre><code>$ cat a# Commentabcd$ ./p dbg.l: (in "a" (list (peek) (char)))-> ("#" "#")</code></pre><dt><a name="pick"><code>(pick 'fun 'lst ..) -> any</code></a><dd>Applies <code>fun</code> to successive elements of <code>lst</code> untilnon-<code>NIL</code> is returned. Returns that value, or <code>NIL</code> if<code>fun</code> did not return non-<code>NIL</code> for any element of<code>lst</code>. When additional <code>lst</code> arguments are given, theirelements are also passed to <code>fun</code>. See also <code><ahref="refS.html#seek">seek</a></code>, <code><ahref="refF.html#find">find</a></code>.<p><pre><code>: (put 'D 'str "Hello")-> "Hello": (pick '((X) (get X 'str)) '(A B C D E F))-> "Hello"</code></pre><dt><a name="pid"><code>(pid 'pid|lst . exe) -> any</code></a><dd>Evaluates <code>exe</code> when the value of the global <code><ahref="refP.html#*Pid">*Pid</a></code> is equal to the <code>pid</code> argument,or a member of the <code>lst</code> argument. Used typically in combination with<code><a href="refT.html#tell">tell</a></code> to send a command selectively toanother process.<p><pre><code>: (tell 'pid 20290 'gc 0) # Tell process 20290 to purge unused heap blocks-> 0</code></pre><dt><a name="pipe"><code>(pipe exe) -> cnt<br>(pipe exe . prg) -> any</code></a><dd>Executes <code>exe</code> in a <code><ahref="refF.html#fork">fork</a></code>'ed child process (which terminatesthereafter). In the first form, <code>pipe</code> just returns a file descriptorto read from the standard output of that process. In the second form, it opensthe standard output of that process as input channel during the execution of<code>prg</code>. The current input channel will be saved and restoredappropriately. See also <code><a href="refI.html#ipid">ipid</a></code>, <code><ahref="refI.html#in">in</a></code> and <code><ahref="refO.html#out">out</a></code>.<p><pre><code>: (pipe # equivalent to 'any' (prinl "(a b # Comment^Jc d)") # (child process) (read) ) # (parent process)-> (a b c d): (pipe # pipe through an external program (out '(tr "[a-z]" "[A-Z]") # (child process) (prinl "abc def ghi") ) (line T) ) # (parent process)-> "ABC DEF GHI"</code></pre><dt><a name="place"><code>(place 'cnt 'lst 'any) -> lst</code></a><dd>Places <code>any</code> into <code>lst</code> at position <code>cnt</code>.See also <code><a href="refI.html#insert">insert</a></code>, <code><ahref="refR.html#remove">remove</a></code>, <code><ahref="refA.html#append">append</a></code>, <code><ahref="refD.html#delete">delete</a></code> and <code><ahref="refR.html#replace">replace</a></code>.<p><pre><code>: (place 3 '(a b c d e) 777)-> (a b 777 d e): (place 1 '(a b c d e) 777)-> (777 b c d e): (place 9 '(a b c d e) 777)-> (a b c d e 777)</code></pre><dt><a name="poll"><code>(poll 'cnt) -> cnt | NIL</code></a><dd>Checks for the availability of data for reading on the file descriptor<code>cnt</code>. See also <code><a href="refO.html#open">open</a></code>,<code><a href="refI.html#in">in</a></code> and <code><ahref="refC.html#close">close</a></code>.<p><pre><code>: (and (poll *Fd) (in @ (read))) # Prevent blocking</code></pre><dt><a name="pool"><code>(pool ['sym1 ['lst] ['sym2]]) -> flg</code></a><dd>Opens the file <code>sym1</code> as a database file in read/write mode. Ifthe file does not exist, it is created. A currently open database is closed.<code>lst</code> is a list of block size scale factors (i.e. numbers),defaulting to (2) (for a single file with a 256 byte block size). If<code>lst</code> is given, an individual database file is opened for each item.If <code>sym2</code> is non-<code>NIL</code>, it is opened in append-mode as ajournal file. Returns <code>T</code> when successful. See also <code><ahref="refD.html#dbs">dbs</a></code>, <code><ahref="refD.html#*Dbs">*Dbs</a></code> and <code><ahref="refJ.html#journal">journal</a></code>.<p><pre><code>: (pool "/dev/hda2")-> T: *Dbs-> (1 2 2 4): (pool "dbFile" *Dbs)-> T:abu:~/pico ls -l dbFile*-rw-r--r-- 1 abu abu 256 2007-06-11 07:57 dbFile1-rw-r--r-- 1 abu abu 13 2007-06-11 07:57 dbFile2-rw-r--r-- 1 abu abu 13 2007-06-11 07:57 dbFile3-rw-r--r-- 1 abu abu 13 2007-06-11 07:57 dbFile4</code></pre><dt><a name="pop"><code>(pop 'var) -> any</code></a><dd>Pops the first element (<code>CAR</code>) from the stack in<code>var</code>. See also <code><a href="refP.html#push">push</a></code>,<code><a href="refQ.html#queue">queue</a></code>, <code><ahref="refC.html#cut">cut</a></code>, <code><ahref="refD.html#del">del</a></code> and <code><ahref="refF.html#fifo">fifo</a></code>.<p><pre><code>: (setq S '((a b c) (1 2 3)))-> ((a b c) (1 2 3)): (pop S)-> a: (pop (cdr S))-> 1: (pop 'S)-> (b c): S-> ((2 3))</code></pre><dt><a name="port"><code>(port ['T] 'cnt|(cnt . cnt) ['var]) -> cnt</code></a><dd>Opens a TCP-Port <code>cnt</code> (or a UDP-Port if the first argument is<code>T</code>), and returns a socket descriptor suitable as an argument for<code><a href="refL.html#listen">listen</a></code> or <code><ahref="refA.html#accept">accept</a></code> (or <code><ahref="refU.html#udp">udp</a></code>, respectively). If <code>cnt</code> is zero,some free port number is allocated. If a pair of <code>cnt</code>s is giveninstead, it should be a range of numbers which are tried in turn. When<code>var</code> is given, it is bound to the port number.<p><pre><code>: (port 0 'A) # Allocate free port-> 4: A-> 1034 # Got 1034: (port (4000 . 4008) 'A) # Try one of these ports-> 5: A-> 4002</code></pre><dt><a name="pp"><code>(pp 'sym) -> sym<br>(pp 'sym 'cls) -> sym<br>(pp '(sym . cls)) -> sym</code></a><dd>Pretty-prints the function or method definition of <code>sym</code>. Theoutput format would regenerate that same definition when read and executed. Seealso <code><a href="refP.html#pretty">pretty</a></code>, <code><ahref="refD.html#debug">debug</a></code> and <code><ahref="refV.html#vi">vi</a></code>.<p><pre><code>: (pp 'tab)(de tab (Lst . @) (for N Lst (let V (next) (and (gt0 N) (space (- N (length V)))) (prin V) (and (lt0 N) (space (- 0 N (length V))) ) ) ) (prinl) )-> tab: (pp 'has> '+Entity)(dm has> (Var Val) (or (nor Val (get This Var)) (has> (meta This Var) Val (get This Var)) ) )-> has>: (more (can 'has>) pp)(dm (has> . +Relation) (Val X) (and (= Val X) X) )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -