84 lines
No EOL
7.5 KiB
HTML
84 lines
No EOL
7.5 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
<title>CLiki: SPLIT-SEQUENCE</title>
|
||
<link rel="alternate" type="application/atom+xml" title="ATOM feed of edits to current article"
|
||
href="https://www.cliki.net/site/feed/article.atom?title=SPLIT-SEQUENCE">
|
||
<link rel="stylesheet" href="static/css/style.css">
|
||
<link rel="stylesheet" href="static/css/colorize.css">
|
||
</head>
|
||
|
||
<body>
|
||
<span class="hidden">CLiki - SPLIT-SEQUENCE</span>
|
||
<div id="content"><div id="content-area"><div id="article-title">SPLIT-SEQUENCE</div><div id="article">SPLIT-SEQUENCE (formerly known as PARTITION) is a member of the <a href="Common Lisp Utilities.html" class="category">Common Lisp Utilities</a> family of programs, designed by community consensus.<p>See also <a href="https://edicl.github.io/cl-ppcre/#split">cl-ppcre:split</a>.<p><i>Function</i> <b>SPLIT-SEQUENCE, SPLIT-SEQUENCE-IF, SPLIT-SEQUENCE-IF-NOT</b><p><b>Syntax:</b><p><b>split-sequence</b> <i>delimiter sequence <tt>&key</tt> count remove-empty-subseqs from-end start end test test-not key</i> => <i>list, index</i><p><b>split-sequence-if</b> <i>predicate sequence <tt>&key</tt> count remove-empty-subseqs from-end start end key</i> => <i>list, index</i><p><b>split-sequence-if-not</b> <i>predicate sequence <tt>&key</tt> count remove-empty-subseqs from-end start end key</i> => <i>list, index</i><p><b>Arguments and Values:</b><p><dl>
|
||
<dt>delimiter</dt>
|
||
<dd>an <i>object</i>.</dd>
|
||
<dt>predicate</dt>
|
||
<dd>a <i>designator</i> for a <i>function</i> of one <i>argument</i> that returns a <i>generalized boolean</i>.</dd>
|
||
<dt>sequence</dt>
|
||
<dd>a <i>proper sequence</i>.</dd>
|
||
<dt>count</dt>
|
||
<dd>an <i>integer</i> or <b>nil</b>. The default is <b>nil</b>.</dd>
|
||
<dt>remove-empty-subseqs</dt>
|
||
<dd>a <i>generalized boolean</i>. The default is <i>false</i>.</dd>
|
||
<dt>from-end</dt>
|
||
<dd>a <i>generalized boolean</i>. The default is <i>false</i>.</dd>
|
||
<dt>start, end</dt>
|
||
<dd>
|
||
<i>bounding index designators</i> of <i>sequence</i>. The defaults for start and <i>end</i> are <tt>0</tt> and <b>nil</b>, respectively.</dd>
|
||
<dt>test</dt>
|
||
<dd>a <i>designator</i> for a <i>function</i> of two <i>arguments</i> that returns a <i>generalized boolean</i>.</dd>
|
||
<dt>test-not</dt>
|
||
<dd>a <i>designator</i> for a <i>function</i> of two <i>arguments</i> that returns a <i>generalized boolean</i>.</dd>
|
||
<dt>key</dt>
|
||
<dd>a <i>designator</i> for a <i>function</i> of one <i>argument</i>, or <b>nil</b>.</dd>
|
||
<dt>list</dt>
|
||
<dd>a <i>proper sequence</i>.</dd>
|
||
<dt>index</dt>
|
||
<dd>an <i>integer</i> greater than or equal to zero, and less than or equal to the <i>length</i> of the <i>sequence</i>.</dd>
|
||
</dl><p><b>Description:</b><p>Splits <i>sequence</i> into a list of subsequences delimited by objects <i>satisfying the test</i>.<p><i>List</i> is a list of sequences of the same kind as <i>sequence</i> that has elements consisting of subsequences of <i>sequence</i> that were delimited in the argument by elements <i>satisfying the test</i>. <i>Index</i> is an index into <i>sequence</i> indicating the unprocessed region, suitable as an argument to <a href="https://www.cliki.net/site/HyperSpec/Body/acc_subseq.html" class="hyperspec">subseq</a> to continue processing in the same manner if desired.<p>The <i>count</i> argument, if supplied, limits the number of subsequences in the first return value; if more than <i>count</i> delimited subsequences exist in <i>sequence</i>, the <i>count</i> leftmost delimited subsequences will be in order in the first return value, and the second return value will be the index into <i>sequence</i> at which processing stopped.<p>If <i>from-end</i> is non-null, <i>sequence</i> is conceptually processed from right to left, accumulating the subsequences in reverse order; <i>from-end</i> only makes a difference in the case of a non-null <i>count</i> argument. In the presence of <i>from-end</i>, the <i>count</i> rightmost delimited subsequences will be in the order that they are in <i>sequence</i> in the first return value, and the second is the index indicating the end of the unprocessed region.<p>The <i>start</i> and <i>end</i> keyword arguments permit a certain subsequence of the <i>sequence</i> to be processed without the need for a copying stage; their use is conceptually equivalent to partitioning the subsequence delimited by <i>start</i> and <i>end</i>, only without the need for copying.<p>If <i>remove-empty-subseqs</i> is null (the default), then empty subsequences will be included in the result.<p>In all cases, the subsequences in the first return value will be in the order that they appeared in <i>sequence</i>.<p>It should be noted that in Common Lisp, strings are sequences and therefore split-sequence can also be used to split strings, and splitting strings is one of the most common use of split-sequence. Notably, newbies often ask about split-string or some other wait to split strings. Split-sequence is the answer to the Common Lisp split string quest.<p><b>Examples:</b><p><pre>
|
||
(split-sequence:SPLIT-SEQUENCE #\Space "A stitch in time saves nine.")
|
||
=> ("A" "stitch" "in" "time" "saves" "nine.")
|
||
28
|
||
(split-sequence:SPLIT-SEQUENCE #\, "foo,bar ,baz, foobar , barbaz,")
|
||
=> ("foo" "bar " "baz" " foobar " " barbaz" "")
|
||
30
|
||
</pre></div></div>
|
||
<div id="footer" class="buttonbar"><ul><li><a href="SPLIT-SEQUENCE.html">Current version</a></li>
|
||
<li><a href="https://www.cliki.net/site/history?article=SPLIT-SEQUENCE">History</a></li>
|
||
<li><a href="https://www.cliki.net/site/backlinks?article=SPLIT-SEQUENCE">Backlinks</a></li><li><a href="https://www.cliki.net/site/edit-article?title=SPLIT-SEQUENCE&from-revision=3824083512">Edit</a></li><li><a href="https://www.cliki.net/site/edit-article?create=t">Create</a></li></ul></div>
|
||
</div>
|
||
<div id="header-buttons" class="buttonbar">
|
||
<ul>
|
||
<li><a href="https://www.cliki.net/">Home</a></li>
|
||
<li><a href="https://www.cliki.net/site/recent-changes">Recent Changes</a></li>
|
||
<li><a href="CLiki.html">About</a></li>
|
||
<li><a href="Text Formatting.html">Text Formatting</a></li>
|
||
<li><a href="https://www.cliki.net/site/tools">Tools</a></li>
|
||
</ul>
|
||
<div id="search">
|
||
<form action="https://www.cliki.net/site/search">
|
||
<label for="search_query" class="hidden">Search CLiki</label>
|
||
<input type="text" name="query" id="search_query" value="" />
|
||
<input type="submit" value="search" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<div id="pageheader">
|
||
<div id="header">
|
||
<span id="logo">CLiki</span>
|
||
<span id="slogan">the common lisp wiki</span>
|
||
<div id="login"><form method="post" action="https://www.cliki.net/site/login">
|
||
<label for="login_name" class="hidden">Account name</label>
|
||
<input type="text" name="name" id="login_name" class="login_input" />
|
||
<label for= "login_password" class="hidden">Password</label>
|
||
<input type="password" name="password" id="login_password" class="login_input" />
|
||
<input type="submit" name="login" value="login" id="login_submit" /><br />
|
||
<div id="register"><a href="https://www.cliki.net/site/register">register</a></div>
|
||
<input type="submit" name="reset-pw" value="reset password" id="reset_pw" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</body></html> |