You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
6 lines
224 KiB
HTML
6 lines
224 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>Sugar: readability & convenience library</title><link rel="stylesheet" type="text/css" href="scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="racket.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-racket.css" title="default"/><script type="text/javascript" src="scribble-common.js"></script><script type="text/javascript" src="manual-racket.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">►</a></td><td></td><td><a href="index.html" class="tocviewselflink" data-pltdoc="x">Sugar:<span class="mywbr"> </span> readability & convenience library</a></td></tr></table></div><div class="tocviewsublistonly" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="index.html#%28part._.Installation___updates%29" class="tocviewlink" data-pltdoc="x">Installation & updates</a></td></tr><tr><td align="right">2 </td><td><a href="index.html#%28part._.Coercion%29" class="tocviewlink" data-pltdoc="x">Coercion</a></td></tr><tr><td align="right">3 </td><td><a href="index.html#%28part._.Container%29" class="tocviewlink" data-pltdoc="x">Container</a></td></tr><tr><td align="right">4 </td><td><a href="index.html#%28part._.Debug%29" class="tocviewlink" data-pltdoc="x">Debug</a></td></tr><tr><td align="right">5 </td><td><a href="index.html#%28part._.File%29" class="tocviewlink" data-pltdoc="x">File</a></td></tr><tr><td align="right">6 </td><td><a href="index.html#%28part._.Len%29" class="tocviewlink" data-pltdoc="x">Len</a></td></tr><tr><td align="right">7 </td><td><a href="index.html#%28part._.List%29" class="tocviewlink" data-pltdoc="x">List</a></td></tr><tr><td align="right">8 </td><td><a href="index.html#%28part._.String%29" class="tocviewlink" data-pltdoc="x">String</a></td></tr><tr><td align="right">9 </td><td><a href="index.html#%28part._.License___source_code%29" class="tocviewlink" data-pltdoc="x">License & source code</a></td></tr></table></div></div></div><div class="tocsub"><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber"></span><a href="#%28part._.Sugar__readability___convenience_library%29" class="tocsubseclink" data-pltdoc="x">Sugar:<span class="mywbr"> </span> readability & convenience library</a></td></tr><tr><td><span class="tocsublinknumber">1<tt> </tt></span><a href="#%28part._.Installation___updates%29" class="tocsubseclink" data-pltdoc="x">Installation & updates</a></td></tr><tr><td><span class="tocsublinknumber">2<tt> </tt></span><a href="#%28part._.Coercion%29" class="tocsubseclink" data-pltdoc="x">Coercion</a></td></tr><tr><td><span class="tocsublinknumber">2.1<tt> </tt></span><a href="#%28part._.Values%29" class="tocsubseclink" data-pltdoc="x">Values</a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>></span>int</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>></span>string</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>></span>symbol</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3epath%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>></span>path</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3ecomplete-path%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>></span>complete-<wbr></wbr>path</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>></span>list</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3evector%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>></span>vector</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eboolean%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>></span>boolean</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._intish~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">intish?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">stringish?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._symbolish~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">symbolish?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">pathish?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._complete-pathish~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">complete-<wbr></wbr>pathish?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._listish~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">listish?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._vectorish~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">vectorish?</span></span></a></td></tr><tr><td><span class="tocsublinknumber">2.2<tt> </tt></span><a href="#%28part._.Coercion_contracts%29" class="tocsubseclink" data-pltdoc="x">Coercion contracts</a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fint~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">coerce/<span class="mywbr"> </span>int?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fstring~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">coerce/<span class="mywbr"> </span>string?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fsymbol~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">coerce/<span class="mywbr"> </span>symbol?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fpath~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">coerce/<span class="mywbr"> </span>path?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fboolean~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">coerce/<span class="mywbr"> </span>boolean?</span></span></a></td></tr><tr><td><span class="tocsublinknumber">3<tt> </tt></span><a href="#%28part._.Container%29" class="tocsubseclink" data-pltdoc="x">Container</a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">get</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">in?</span></span></a></td></tr><tr><td><span class="tocsublinknumber">4<tt> </tt></span><a href="#%28part._.Debug%29" class="tocsubseclink" data-pltdoc="x">Debug</a></td></tr><tr><td><a href="#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">report</span></span></a></td></tr><tr><td><span class="tocsublinknumber">5<tt> </tt></span><a href="#%28part._.File%29" class="tocsubseclink" data-pltdoc="x">File</a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">get-<wbr></wbr>ext</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">has-<wbr></wbr>ext?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">remove-<wbr></wbr>ext</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">remove-<wbr></wbr>ext*</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">add-<wbr></wbr>ext</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">get-<wbr></wbr>enclosing-<wbr></wbr>dir</span></span></a></td></tr><tr><td><span class="tocsublinknumber">6<tt> </tt></span><a href="#%28part._.Len%29" class="tocsubseclink" data-pltdoc="x">Len</a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">len</span></span></a></td></tr><tr><td><span class="tocsublinknumber">7<tt> </tt></span><a href="#%28part._.List%29" class="tocsubseclink" data-pltdoc="x">List</a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Flist..rkt%29._trimf%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">trimf</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Flist..rkt%29._filter-split%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">filter-<wbr></wbr>split</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Flist..rkt%29._frequency-hash%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">frequency-<wbr></wbr>hash</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">members-<wbr></wbr>unique?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%2Ferror%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">members-<wbr></wbr>unique?/<span class="mywbr"> </span>error</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._sugar%2Flist..rkt%29._when%2Fsplice%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">when/<span class="mywbr"> </span>splice</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._sugar%2Flist..rkt%29._values-~3elist%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">values-<wbr></wbr>>list</span></span></a></td></tr><tr><td><span class="tocsublinknumber">8<tt> </tt></span><a href="#%28part._.String%29" class="tocsubseclink" data-pltdoc="x">String</a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fstring..rkt%29._starts-with~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">starts-<wbr></wbr>with?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fstring..rkt%29._ends-with~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">ends-<wbr></wbr>with?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fstring..rkt%29._capitalized~3f%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">capitalized?</span></span></a></td></tr><tr><td><span class="tocsublinknumber">9<tt> </tt></span><a href="#%28part._.License___source_code%29" class="tocsubseclink" data-pltdoc="x">License & source code</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="versionNoNav">6.0.1.13</span></div><h2><a name="(part._.Sugar__readability___convenience_library)"></a><a name="(mod-path._sugar)"></a>Sugar: readability & convenience library</h2><div class="SAuthorListBox"><span class="SAuthorList"><p class="author">Matthew Butterick <<a href="mailto:mb@mbtype.com">mb@mbtype.com</a>></p></span></div><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">sugar</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">sugar</span></span></td></tr></table></p><p>A collection of small functions to help make Racket code simpler & more readable.</p><h3>1<tt> </tt><a name="(part._.Installation___updates)"></a>Installation & updates</h3><p><div class="SIntrapara">At the command line:
|
|
</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">raco pkg install sugar</span></p></td></tr></table></div></p><p><div class="SIntrapara">After that, you can update the package from the command line:
|
|
</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">raco pkg update sugar</span></p></td></tr></table></div></p><h3>2<tt> </tt><a name="(part._.Coercion)"></a><a name="(mod-path._sugar/coerce)"></a>Coercion</h3><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="index.html#%28mod-path._sugar%2Fcoerce%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">sugar/coerce</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">sugar</span></span></td></tr></table></p><p>Functions that coerce the datatype of a value to another type. Racket already has type-specific conversion functions. But if you’re handling values of indeterminate type — as sometimes happens in an untyped language — then handling the possible cases individually gets to be a drag.</p><h4>2.1<tt> </tt><a name="(part._.Values)"></a>Values</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._-~3eint))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValDef RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Convert <span class="RktVar">v</span> to an integer in the least surprising way, or raise an error if no conversion is possible.</div></p><p>Numbers are rounded down to the nearest integer.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktVal">3.5</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktVal"><span class="nobreak">-2</span>.5</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">-3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2F%29%29" class="RktValLink" data-pltdoc="x">/</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr></table></blockquote></td></tr></table></p><p>Stringlike values — paths, symbols, and strings — are converted to numbers and rounded down.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktVal">"3.5"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">3.5</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"3.5"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr></table></blockquote></td></tr></table></p><p>Characters are directly converted to integers.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">65</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktVal">#\◊</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">9674</span></p></td></tr></table></blockquote></td></tr></table></p><p>Lists, vectors, and other multi-value datatypes return their length (using <span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span>).</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">6</span><span class="hspace"> </span><span class="RktVal">7</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash%29%29" class="RktValLink" data-pltdoc="x">hash</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara">The function will raise an error if no sensible conversion is possible.
|
|
</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>int</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">Can’t convert #t to integer</span></p></td></tr></table></blockquote></td></tr></table></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._-~3estring))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValDef RktValLink" data-pltdoc="x"><span class="nobreak">-></span>string</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return the most natural string representation of <span class="RktVar">v</span>, or raise an error if none exists.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>string</a></span><span class="hspace"> </span><span class="RktVal">"string"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"string"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>string</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">symbol</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"symbol"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>string</a></span><span class="hspace"> </span><span class="RktVal">98.6</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"98.6"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>string</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"stdio.h"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"stdio.h"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>string</a></span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"A"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>string</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">Can’t convert #t to string</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._-~3esymbol))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29" class="RktValDef RktValLink" data-pltdoc="x"><span class="nobreak">-></span>symbol</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Same as <span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>string</a></span>, but return a symbol rather than a string.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>symbol</a></span><span class="hspace"> </span><span class="RktVal">"string"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'string</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>symbol</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">symbol</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'symbol</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>symbol</a></span><span class="hspace"> </span><span class="RktVal">98.6</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'|98.6|</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>symbol</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"stdio.h"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'stdio.h</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>symbol</a></span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'A</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>symbol</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">Can’t convert #t to symbol</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._-~3epath))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3epath%29%29" class="RktValDef RktValLink" data-pltdoc="x"><span class="nobreak">-></span>path</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._-~3ecomplete-path))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3ecomplete-path%29%29" class="RktValDef RktValLink" data-pltdoc="x"><span class="nobreak">-></span>complete-path</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._complete-path~3f%29%29" class="RktValLink" data-pltdoc="x">complete-path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Same as <span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>string</a></span>, but return a path (or complete path) rather than a string.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3epath%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>path</a></span><span class="hspace"> </span><span class="RktVal">"string"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:string></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3epath%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>path</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">symbol</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:symbol></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3ecomplete-path%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>complete-path</a></span><span class="hspace"> </span><span class="RktVal">98.6</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/Users/mb/git/sugar/98.6></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3ecomplete-path%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>complete-path</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"stdio.h"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/Users/mb/git/sugar/stdio.h></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3ecomplete-path%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>complete-path</a></span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/Users/mb/git/sugar/A></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3ecomplete-path%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>complete-path</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">Can’t convert #t to complete-path</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._-~3elist))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="RktValDef RktValLink" data-pltdoc="x"><span class="nobreak">-></span>list</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">If <span class="RktVar">v</span> is a listlike data type — a vector, set, stream, sequence, or list — convert it to a list. A hash or dictionary becomes a list using <span class="RktSym"><a href="http://docs.racket-lang.org/reference/dicts.html#%28def._%28%28lib._racket%2Fdict..rkt%29._dict-~3elist%29%29" class="RktValLink" data-pltdoc="x">dict->list</a></span>. If <span class="RktVar">v</span> is an atomic value, turn it into a single-member list.</div></p><p>Note that a string is treated as an atomic value rather than decomposed with <span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string-~3elist%29%29" class="RktValLink" data-pltdoc="x">string->list</a></span>. This is done so the function handles strings the same way as symbols and paths.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>list</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(a b c)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._list-~3evector%29%29" class="RktValLink" data-pltdoc="x">list->vector</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(a b c)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-hash%29%29" class="RktValLink" data-pltdoc="x">make-hash</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">k</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">v</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">k2</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">v2</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((k . v) (k2 . v2))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>list</a></span><span class="hspace"> </span><span class="RktVal">"string"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'("string")</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>list</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">symbol</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(symbol)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"path"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#<path:path>)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>list</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#<procedure:+>)</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._-~3evector))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3evector%29%29" class="RktValDef RktValLink" data-pltdoc="x"><span class="nobreak">-></span>vector</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector~3f%29%29" class="RktValLink" data-pltdoc="x">vector?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Same as <span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3elist%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>list</a></span>, but returns a vector rather than a list.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3evector%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>vector</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(a b c)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3evector%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>vector</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._list-~3evector%29%29" class="RktValLink" data-pltdoc="x">list->vector</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(a b c)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3evector%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>vector</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-hash%29%29" class="RktValLink" data-pltdoc="x">make-hash</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">k</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">v</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">k2</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">v2</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#((k . v) (k2 . v2))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3evector%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>vector</a></span><span class="hspace"> </span><span class="RktVal">"string"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#("string")</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3evector%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>vector</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">symbol</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(symbol)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3evector%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>vector</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"path"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(#<path:path>)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3evector%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>vector</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(#<procedure:+>)</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._-~3eboolean))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eboolean%29%29" class="RktValDef RktValLink" data-pltdoc="x"><span class="nobreak">-></span>boolean</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return <span class="RktVal">#t</span> for all <span class="RktVar">v</span> except <span class="RktVal">#f</span>, which remains <span class="RktVal">#f</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eboolean%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>boolean</a></span><span class="hspace"> </span><span class="RktVal">"string"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eboolean%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>boolean</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">symbol</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eboolean%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>boolean</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eboolean%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>boolean</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">l</span><span class="hspace"> </span><span class="RktVal">i</span><span class="hspace"> </span><span class="RktVal">s</span><span class="hspace"> </span><span class="RktVal">t</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eboolean%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-></span>boolean</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._intish~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._intish~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">intish?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._stringish~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">stringish?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._symbolish~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._symbolish~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">symbolish?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._pathish~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">pathish?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._complete-pathish~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._complete-pathish~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">complete-pathish?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._listish~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._listish~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">listish?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._vectorish~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._vectorish~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">vectorish?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Predicates that report whether <span class="RktVar">v</span> can be coerced to the specified type.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._intish~3f%29%29" class="RktValLink" data-pltdoc="x">intish?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">3.5</span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="hspace"> </span><span class="RktVal">"A"</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#t #t #t #f #f #f)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">3.5</span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="hspace"> </span><span class="RktVal">"A"</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#t #t #t #t #f #f)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._symbolish~3f%29%29" class="RktValLink" data-pltdoc="x">symbolish?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">3.5</span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="hspace"> </span><span class="RktVal">"A"</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#t #t #t #t #f #f)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">3.5</span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="hspace"> </span><span class="RktVal">"A"</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#t #t #t #t #f #f)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._complete-pathish~3f%29%29" class="RktValLink" data-pltdoc="x">complete-pathish?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">3.5</span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="hspace"> </span><span class="RktVal">"A"</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#t #t #t #t #f #f)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._listish~3f%29%29" class="RktValLink" data-pltdoc="x">listish?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">3.5</span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="hspace"> </span><span class="RktVal">"A"</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#t #t #t #t #t #t)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._vectorish~3f%29%29" class="RktValLink" data-pltdoc="x">vectorish?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">3.5</span><span class="hspace"> </span><span class="RktVal">#\A</span><span class="hspace"> </span><span class="RktVal">"A"</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#t #t #t #t #t #t)</span></p></td></tr></table></blockquote></td></tr></table></p><h4>2.2<tt> </tt><a name="(part._.Coercion_contracts)"></a>Coercion contracts</h4><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._coerce/int~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fint~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">coerce/int?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._coerce/string~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fstring~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">coerce/string?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._coerce/symbol~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fsymbol~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">coerce/symbol?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._coerce/path~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fpath~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">coerce/path?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="together"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._coerce/boolean~3f))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fboolean~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">coerce/boolean?</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">If <span class="RktVar">v</span> can be coerced to the specified type, change it to that type, then return it. If not, raise the usual contract error. These contracts can be used with input or output values.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/attaching-contracts-to-values.html#%28form._%28%28lib._racket%2Fcontract%2Fregion..rkt%29._define%2Fcontract%29%29" class="RktStxLink" data-pltdoc="x">define/contract</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">add-ints</span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fint~3f%29%29" class="RktValLink" data-pltdoc="x">coerce/int?</a></span><span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fint~3f%29%29" class="RktValLink" data-pltdoc="x">coerce/int?</a></span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="RktPn"> .</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="RktCmt">Input arguments will be coerced to integers, then added</span></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">add-ints</span><span class="hspace"> </span><span class="RktVal">1.6</span><span class="hspace"> </span><span class="RktVal">3.8</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">4</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/attaching-contracts-to-values.html#%28form._%28%28lib._racket%2Fcontract%2Fregion..rkt%29._define%2Fcontract%29%29" class="RktStxLink" data-pltdoc="x">define/contract</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">int-sum</span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="RktPn"> .</span><span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._coerce%2Fint~3f%29%29" class="RktValLink" data-pltdoc="x">coerce/int?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="RktCmt">Input arguments will be added, and the result coerced to an integer</span></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">int-sum</span><span class="hspace"> </span><span class="RktVal">1.6</span><span class="hspace"> </span><span class="RktVal">3.8</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">5</span></p></td></tr></table></blockquote></td></tr></table></p><p>Please note: this is not an officially sanctioned way to use Racket’s contract system, because contracts aren’t supposed to mutate their values (see <span class="RktSym"><a href="http://docs.racket-lang.org/reference/Building_New_Contract_Combinators.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fprop..rkt%29._make-contract%29%29" class="RktValLink" data-pltdoc="x">make-contract</a></span>).</p><p>But coercion contracts can be useful in two situations:</p><ul><li><p>You want to be liberal about input types, but don’t want to deal with the housekeeping and manual conversions between types.</p></li><li><p>Your contract involves an expensive operation that you’d rather avoid performing twice.</p></li></ul><h3>3<tt> </tt><a name="(part._.Container)"></a><a name="(mod-path._sugar/container)"></a>Container</h3><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="index.html#%28mod-path._sugar%2Fcontainer%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">sugar/container</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">sugar</span></span></td></tr></table></p><p>Type-neutral functions for getting elements out of a container, or testing membership.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/container..rkt)._get))"></a><span title="Provided from: sugar/container | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValDef RktValLink" data-pltdoc="x">get</a></span></span><span class="hspace"> </span><span class="RktVar">container</span><span class="hspace"> </span><span class="RktVar">which</span><span class="hspace"> </span>[<span class="RktVar">end_which</span>]<span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">container</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector~3f%29%29" class="RktValLink" data-pltdoc="x">vector?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/sequences.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._sequence~3f%29%29" class="RktValLink" data-pltdoc="x">sequence?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/dicts.html#%28def._%28%28lib._racket%2Fdict..rkt%29._dict~3f%29%29" class="RktValLink" data-pltdoc="x">dict?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">which</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">end_which</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._and%2Fc%29%29" class="RktValLink" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._positive~3f%29%29" class="RktValLink" data-pltdoc="x">positive?</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">#f</span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktVal">#f</span></td></tr></table></blockquote></div><div class="SIntrapara">For a <span class="RktVar">container</span> that’s a <span class="RktSym"><a href="http://docs.racket-lang.org/reference/dicts.html#%28def._%28%28lib._racket%2Fdict..rkt%29._dict~3f%29%29" class="RktValLink" data-pltdoc="x">dict?</a></span>, retrieve the element associated with the key <span class="RktVar">which</span>. Raise an error if the key doesn’t exist.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-hash%29%29" class="RktValLink" data-pltdoc="x">make-hash</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">1</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">b</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">2</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-hash%29%29" class="RktValLink" data-pltdoc="x">make-hash</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">1</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">z</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">get: couldn’t retrieve item z from #hash((b . 2) (a . 1) (c</span></p></td></tr><tr><td><p><span class="RktErr">. 3))</span></p></td></tr></table></blockquote></td></tr></table></p><p>For other <span class="RktVar">container</span> types — which are all sequence-like — retrieve the element located at <span class="RktVar">which</span>. Or if the optional <span class="RktVar">end_which</span> argument is provided, retrieve the elements from <span class="RktVar">which</span> to <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._sub1%29%29" class="RktValLink" data-pltdoc="x">sub1</a></span><span class="stt"> </span><span class="RktVar">end_which</span><span class="RktPn">)</span>, inclusive (i.e., make a slice). Raise an error if <span class="RktVar">which</span> or <span class="RktVar">end_which</span> is out of bounds.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">2</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(2 3)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">100</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">get: couldn’t retrieve item 100 from (0 1 2 3 4 5)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">100</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">get: couldn’t retrieve items 2 through 100 from (0 1 2 3 4</span></p></td></tr><tr><td><p><span class="RktErr">5)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._list-~3evector%29%29" class="RktValLink" data-pltdoc="x">list->vector</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">2</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._list-~3evector%29%29" class="RktValLink" data-pltdoc="x">list->vector</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(2 3)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktVal">"purple"</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"r"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktVal">"purple"</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"rp"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">purple</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'r</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">purple</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'rp</span></p></td></tr></table></blockquote></td></tr></table></p><p>When <span class="RktVar">container</span> is a path, it’s treated as a list of path elements (created by <span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._explode-path%29%29" class="RktValLink" data-pltdoc="x">explode-path</a></span>), not as a stringlike value.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"/root/foo/bar/file.txt"</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">1</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:root></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"/root/foo/bar/file.txt"</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(#<path:/> #<path:root> #<path:foo>)</span></p></td></tr></table></blockquote></td></tr></table></p><p>To slice to the end of <span class="RktVar">container</span>, use <span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="stt"> </span><span class="RktVar">container</span><span class="RktPn">)</span> as the value of <span class="RktVar">end_which</span>.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">xs</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktSym">xs</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktSym">xs</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(2 3 4 5)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._list-~3evector%29%29" class="RktValLink" data-pltdoc="x">list->vector</a></span><span class="hspace"> </span><span class="RktSym">xs</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._list-~3evector%29%29" class="RktValLink" data-pltdoc="x">list->vector</a></span><span class="hspace"> </span><span class="RktSym">xs</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#(2 3 4 5)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">color</span><span class="hspace"> </span><span class="RktVal">"purple"</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span><span class="hspace"> </span><span class="RktSym">color</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktSym">color</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"rple"</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/container..rkt)._in~3f))"></a><span title="Provided from: sugar/container | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">in?</a></span></span><span class="hspace"> </span><span class="RktVar">item</span><span class="hspace"> </span><span class="RktVar">container</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">item</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">container</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector~3f%29%29" class="RktValLink" data-pltdoc="x">vector?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/sequences.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._sequence~3f%29%29" class="RktValLink" data-pltdoc="x">sequence?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/sets.html#%28def._%28%28lib._racket%2Fset..rkt%29._set~3f%29%29" class="RktValLink" data-pltdoc="x">set?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/dicts.html#%28def._%28%28lib._racket%2Fdict..rkt%29._dict~3f%29%29" class="RktValLink" data-pltdoc="x">dict?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Return <span class="RktVal">#t</span> if <span class="RktVar">item</span> is in <span class="RktVar">container</span>, or <span class="RktVal">#f</span> otherwise.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValLink" data-pltdoc="x">in?</a></span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValLink" data-pltdoc="x">in?</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValLink" data-pltdoc="x">in?</a></span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._list-~3evector%29%29" class="RktValLink" data-pltdoc="x">list->vector</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">0</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValLink" data-pltdoc="x">in?</a></span><span class="hspace"> </span><span class="RktVal">"pu"</span><span class="hspace"> </span><span class="RktVal">"purple"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValLink" data-pltdoc="x">in?</a></span><span class="hspace"> </span><span class="RktVal">"zig"</span><span class="hspace"> </span><span class="RktVal">"purple"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValLink" data-pltdoc="x">in?</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-hash%29%29" class="RktValLink" data-pltdoc="x">make-hash</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">1</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValLink" data-pltdoc="x">in?</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">z</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-hash%29%29" class="RktValLink" data-pltdoc="x">make-hash</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">1</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p>As with <span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._get%29%29" class="RktValLink" data-pltdoc="x">get</a></span>, when <span class="RktVar">container</span> is a path, it’s treated as a list of exploded path elements, not as a stringlike value.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValLink" data-pltdoc="x">in?</a></span><span class="hspace"> </span><span class="RktVal">"foo"</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"/root/foo/bar/file.txt"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcontainer..rkt%29._in~3f%29%29" class="RktValLink" data-pltdoc="x">in?</a></span><span class="hspace"> </span><span class="RktVal">"zam"</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"/root/foo/bar/file.txt"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><h3>4<tt> </tt><a name="(part._.Debug)"></a><a name="(mod-path._sugar/debug)"></a>Debug</h3><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="index.html#%28mod-path._sugar%2Fdebug%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">sugar/debug</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">sugar</span></span></td></tr></table></p><p>Debugging utilities.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._sugar/debug..rkt)._report))"></a><span title="Provided from: sugar/debug | Package: sugar"><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">report</a></span></span><span class="hspace"> </span><span class="RktVar">expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Print the name and value of <span class="RktVar">expr</span> to <span class="RktSym"><a href="http://docs.racket-lang.org/reference/port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-error-port%29%29" class="RktValLink" data-pltdoc="x">current-error-port</a></span>, but also return the evaluated result of <span class="RktVar">expr</span> as usual. This lets you see the value of an expression or variable at runtime without disrupting any of the surrounding code.</div></p><p>For instance, suppose you wanted to see how <span class="RktSym">first-condition?</span> was being evaluted in this expression:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">first-condition?</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">second-condition?</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">one-thing</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">other-thing</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>You can wrap it in <span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29" class="RktStxLink" data-pltdoc="x">report</a></span> and find out:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29" class="RktStxLink" data-pltdoc="x">report</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">first-condition?</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">second-condition?</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">one-thing</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">other-thing</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>This code will run the same way as before. But when it reaches <span class="RktSym">first-condition?</span>, you willl see in <span class="RktSym"><a href="http://docs.racket-lang.org/reference/port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-error-port%29%29" class="RktValLink" data-pltdoc="x">current-error-port</a></span>:</p><p><span class="RktErr">(first-condition? x) = #t</span></p><p>You can also add standalone calls to <span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29" class="RktStxLink" data-pltdoc="x">report</a></span> as a debugging aid at points where the return value will be irrelevant, for instance:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29" class="RktStxLink" data-pltdoc="x">report</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29" class="RktStxLink" data-pltdoc="x">report</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">first-condition?</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">second-condition?</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">one-thing</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">other-thing</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p><span class="RktErr">x = 42
|
|
<br/>(first-condition? x) = #t</span></p><p>But be careful — in the example below, the result of the <span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span> expression will be skipped in favor of the last expression, which will be the value of <span class="RktVar">x</span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29" class="RktStxLink" data-pltdoc="x">report</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">first-condition?</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">second-condition?</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">one-thing</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">other-thing</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29" class="RktStxLink" data-pltdoc="x">report</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr></table></blockquote><h3>5<tt> </tt><a name="(part._.File)"></a><a name="(mod-path._sugar/file)"></a>File</h3><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="index.html#%28mod-path._sugar%2Ffile%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">sugar/file</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">sugar</span></span></td></tr></table></p><p>File utilities, mostly in the realm of file extensions. These functions don’t access the filesystem.</p><p>Arguments that are <span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span> can take either a string or a path. For clarity below, I’ve used strings.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._get-ext))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValDef RktValLink" data-pltdoc="x">get-ext</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktVal">#f</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return the last file extension of <span class="RktVar">file-path</span> as a string, or <span class="RktVal">#f</span> if it has no extension. Omit the intervening <span class="RktInBG"><span class="hspace"></span><span class="RktIn">.</span><span class="hspace"></span></span> separator.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"txt"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"txt"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"bar"</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/file-without-extension"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29" class="RktValLink" data-pltdoc="x">get-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/directory/"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._has-ext~3f))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">has-ext?</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span><span class="RktVar">ext</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">ext</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return <span class="RktVal">#t</span> if the last file extension of <span class="RktVar">file-path</span> is <span class="RktVar">ext</span>, otherwise <span class="RktVal">#f</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="RktValLink" data-pltdoc="x">has-ext?</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="hspace"> </span><span class="RktVal">"txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="RktValLink" data-pltdoc="x">has-ext?</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="hspace"> </span><span class="RktVal">"jpg"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._has-ext~3f%29%29" class="RktValLink" data-pltdoc="x">has-ext?</a></span><span class="hspace"> </span><span class="RktVal">"foo.jpg.txt"</span><span class="hspace"> </span><span class="RktVal">"jpg"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._remove-ext))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValDef RktValLink" data-pltdoc="x">remove-ext</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Remove the last file extension of <span class="RktVar">file-path</span>, and return the path that remains. If <span class="RktVar">file-path</span> has no extension, you just get the same <span class="RktVar">file-path</span>. Does not use the filesystem.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo.txt></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._remove-ext*))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValDef RktValLink" data-pltdoc="x">remove-ext*</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span>, just more. Remove all file extensions from <span class="RktVar">file-path</span>, and return the path that remains. If <span class="RktVar">file-path</span> has no extensions, you just get the same <span class="RktVar">file-path</span>. Does not use the filesystem.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%2A%29%29" class="RktValLink" data-pltdoc="x">remove-ext*</a></span><span class="hspace"> </span><span class="RktVal">"/path/to/foo.txt.bar"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/path/to/foo></span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._add-ext))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValDef RktValLink" data-pltdoc="x">add-ext</a></span></span><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span><span class="RktVar">ext</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">file-path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">ext</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return a new <span class="RktVar">file-path</span> with <span class="RktVar">ext</span> appended. Note that this does not replace an existing file extension. If that’s what you want, then do <span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValLink" data-pltdoc="x">add-ext</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="stt"> </span><span class="RktVar">file-path</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktVar">ext</span><span class="RktPn">)</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValLink" data-pltdoc="x">add-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo"</span><span class="hspace"> </span><span class="RktVal">"txt"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo.txt></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValLink" data-pltdoc="x">add-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="hspace"> </span><span class="RktVal">"jpg"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo.txt.jpg></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._add-ext%29%29" class="RktValLink" data-pltdoc="x">add-ext</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._remove-ext%29%29" class="RktValLink" data-pltdoc="x">remove-ext</a></span><span class="hspace"> </span><span class="RktVal">"foo.txt"</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"jpg"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:foo.jpg></span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/file..rkt)._get-enclosing-dir))"></a><span title="Provided from: sugar/file | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValDef RktValLink" data-pltdoc="x">get-enclosing-dir</a></span></span><span class="hspace"> </span><span class="RktVar">path</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">path</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._pathish~3f%29%29" class="RktValLink" data-pltdoc="x">pathish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return the enclosing directory of <span class="RktVar">path</span>. Does not consult the filesystem about whether <span class="RktVar">path</span> is valid. If you reach the <span class="RktVar">root</span> directory, then <span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="stt"> </span><span class="RktVar">root</span><span class="RktPn">)</span> will just return <span class="RktVar">root</span> again.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">bin</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"/usr/bin"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktSym">bin</span></td></tr><tr><td><p><span class="RktRes">#<path:/usr/bin></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktSym">bin</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/usr/></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktSym">bin</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/></span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-enclosing-dir%29%29" class="RktValLink" data-pltdoc="x">get-enclosing-dir</a></span><span class="hspace"> </span><span class="RktSym">bin</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#<path:/></span></p></td></tr></table></blockquote></td></tr></table></p><h3>6<tt> </tt><a name="(part._.Len)"></a><a name="(mod-path._sugar/len)"></a>Len</h3><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="index.html#%28mod-path._sugar%2Flen%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">sugar/len</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">sugar</span></span></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/len..rkt)._len))"></a><span title="Provided from: sugar/len | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValDef RktValLink" data-pltdoc="x">len</a></span></span><span class="hspace"> </span><span class="RktVar">x</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">x</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector~3f%29%29" class="RktValLink" data-pltdoc="x">vector?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/sets.html#%28def._%28%28lib._racket%2Fset..rkt%29._set~3f%29%29" class="RktValLink" data-pltdoc="x">set?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash~3f%29%29" class="RktValLink" data-pltdoc="x">hash?</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Calculate the length of <span class="RktVar">x</span> in the least surprising way possible, or if it can’t be done, raise an error. Named in honor of the original discover of the length-reticulation algorithm, Prof. Leonard Spottiswoode.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._list-~3evector%29%29" class="RktValLink" data-pltdoc="x">list->vector</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">abc</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktVal">"abc"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._string-~3epath%29%29" class="RktValLink" data-pltdoc="x">string->path</a></span><span class="hspace"> </span><span class="RktVal">"abc"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-hash%29%29" class="RktValLink" data-pltdoc="x">make-hash</a></span><span class="hspace"> </span><span class="RktVal">`</span><span class="RktVal">(</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">1</span><span class="RktVal">)</span><span class="RktVal">(</span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">2</span><span class="RktVal">)</span><span class="RktVal">(</span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">. </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr></table></blockquote></td></tr></table></p><p>Perhaps ironically, positive integers do not have a length.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flen..rkt%29._len%29%29" class="RktValLink" data-pltdoc="x">len</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">len: can’t calculate length of 3</span></p></td></tr></table></blockquote></td></tr></table></p><h3>7<tt> </tt><a name="(part._.List)"></a><a name="(mod-path._sugar/list)"></a>List</h3><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="index.html#%28mod-path._sugar%2Flist%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">sugar/list</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">sugar</span></span></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/list..rkt)._trimf))"></a><span title="Provided from: sugar/list | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._trimf%29%29" class="RktValDef RktValLink" data-pltdoc="x">trimf</a></span></span><span class="hspace"> </span><span class="RktVar">lst</span><span class="hspace"> </span><span class="RktVar">pred</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">lst</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">pred</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/procedures.html#%28def._%28%28quote._~23~25kernel%29._procedure~3f%29%29" class="RktValLink" data-pltdoc="x">procedure?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Drop elements from each end of <span class="RktVar">lst</span> that satisfy <span class="RktVar">pred</span>. Exactly equivalent to <span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._dropf-right%29%29" class="RktValLink" data-pltdoc="x">dropf-right</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._dropf%29%29" class="RktValLink" data-pltdoc="x">dropf</a></span><span class="stt"> </span><span class="RktVar">lst</span><span class="stt"> </span><span class="RktVar">pred</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktVar">pred</span><span class="RktPn">)</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._trimf%29%29" class="RktValLink" data-pltdoc="x">trimf</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">6</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(a b c)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._trimf%29%29" class="RktValLink" data-pltdoc="x">trimf</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(a b c)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._trimf%29%29" class="RktValLink" data-pltdoc="x">trimf</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(a b c)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._trimf%29%29" class="RktValLink" data-pltdoc="x">trimf</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(a b c 1 2 3 d e f)</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/list..rkt)._filter-split))"></a><span title="Provided from: sugar/list | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._filter-split%29%29" class="RktValDef RktValLink" data-pltdoc="x">filter-split</a></span></span><span class="hspace"> </span><span class="RktVar">lst</span><span class="hspace"> </span><span class="RktVar">pred</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._listof%29%29" class="RktValLink" data-pltdoc="x">listof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">lst</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">pred</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/procedures.html#%28def._%28%28quote._~23~25kernel%29._procedure~3f%29%29" class="RktValLink" data-pltdoc="x">procedure?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28lib._racket%2Fstring..rkt%29._string-split%29%29" class="RktValLink" data-pltdoc="x">string-split</a></span>, but for lists. Drop elements from anywhere in <span class="RktVar">lst</span> that satisfy <span class="RktVar">pred</span> — ends, middle, you name it — and return a list of the sublists that remain.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._filter-split%29%29" class="RktValLink" data-pltdoc="x">filter-split</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((a b c) (d e f))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._filter-split%29%29" class="RktValLink" data-pltdoc="x">filter-split</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Flist..rkt%29._compose%29%29" class="RktValLink" data-pltdoc="x">compose</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._not%29%29" class="RktValLink" data-pltdoc="x">not</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((1) (2) (3))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._filter-split%29%29" class="RktValLink" data-pltdoc="x">filter-split</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((a b c) (d e f))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._filter-split%29%29" class="RktValLink" data-pltdoc="x">filter-split</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Flist..rkt%29._compose%29%29" class="RktValLink" data-pltdoc="x">compose</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._not%29%29" class="RktValLink" data-pltdoc="x">not</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._integer~3f%29%29" class="RktValLink" data-pltdoc="x">integer?</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((1 2 3))</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/list..rkt)._frequency-hash))"></a><span title="Provided from: sugar/list | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._frequency-hash%29%29" class="RktValDef RktValLink" data-pltdoc="x">frequency-hash</a></span></span><span class="hspace"> </span><span class="RktVar">lst</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash~3f%29%29" class="RktValLink" data-pltdoc="x">hash?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">lst</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Count the frequency of each element in <span class="RktVar">lst</span>, and return a hash whose keys are the unique elements of <span class="RktVar">lst</span>, and each value is the frequency of that element within <span class="RktVar">lst</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._frequency-hash%29%29" class="RktValLink" data-pltdoc="x">frequency-hash</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#hash((c . 3) (a . 1) (b . 2))</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._frequency-hash%29%29" class="RktValLink" data-pltdoc="x">frequency-hash</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#hash((c . 3) (a . 1) (b . 2))</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/list..rkt)._members-unique~3f))"></a><span title="Provided from: sugar/list | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">members-unique?</a></span></span><span class="hspace"> </span><span class="RktVar">container</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">container</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector~3f%29%29" class="RktValLink" data-pltdoc="x">vector?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Return <span class="RktVal">#t</span> if every element in <span class="RktVar">container</span> is unique, otherwise <span class="RktVal">#f</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%29%29" class="RktValLink" data-pltdoc="x">members-unique?</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%29%29" class="RktValLink" data-pltdoc="x">members-unique?</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="hspace"> </span><span class="RktVal">a</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/list..rkt)._members-unique~3f/error))"></a><span title="Provided from: sugar/list | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%2Ferror%29%29" class="RktValDef RktValLink" data-pltdoc="x">members-unique?/error</a></span></span><span class="hspace"> </span><span class="RktVar">container</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">container</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector~3f%29%29" class="RktValLink" data-pltdoc="x">vector?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Same as <span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%29%29" class="RktValLink" data-pltdoc="x">members-unique?</a></span>, but if the members are not unique, raises a descriptive error rather than returning <span class="RktVal">#f</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%2Ferror%29%29" class="RktValLink" data-pltdoc="x">members-unique?/error</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%2Ferror%29%29" class="RktValLink" data-pltdoc="x">members-unique?/error</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="hspace"> </span><span class="RktVal">a</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">members-unique? failed because item isn’t unique: (a)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Flist..rkt%29._members-unique~3f%2Ferror%29%29" class="RktValLink" data-pltdoc="x">members-unique?/error</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="hspace"> </span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">members-unique? failed because items aren’t unique: (a b)</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._sugar/list..rkt)._when/splice))"></a><span title="Provided from: sugar/list | Package: sugar"><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Flist..rkt%29._when%2Fsplice%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">when/splice</a></span></span><span class="hspace"> </span><span class="RktVar">test</span><span class="hspace"> </span><span class="RktVar">expr</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A special version of <span class="RktSym"><a href="http://docs.racket-lang.org/reference/when_unless.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._when%29%29" class="RktStxLink" data-pltdoc="x">when</a></span> that you can use inside <span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._quasiquote%29%29" class="RktStxLink" data-pltdoc="x">quasiquote</a></span> to suppress <span class="RktSym"><a href="http://docs.racket-lang.org/reference/void.html#%28def._%28%28quote._~23~25kernel%29._void%29%29" class="RktValLink" data-pltdoc="x">void</a></span> values when <span class="RktVar">test</span> is <span class="RktVal">#f</span>. As the name suggests, it works in conjunction with the <span class="RktInBG"><span class="hspace"></span><span class="RktIn">@</span><span class="hspace"></span></span> splicing operator.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktVal">`</span><span class="RktVal">(</span><span class="RktRdr">,</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/when_unless.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._when%29%29" class="RktStxLink" data-pltdoc="x">when</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._even~3f%29%29" class="RktValLink" data-pltdoc="x">even?</a></span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"hooray"</span><span class="RktPn">)</span><span class="RktVal">)</span></td></tr><tr><td><p><span class="RktRes">'("hooray")</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktVal">`</span><span class="RktVal">(</span><span class="RktRdr">,</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/when_unless.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._when%29%29" class="RktStxLink" data-pltdoc="x">when</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._even~3f%29%29" class="RktValLink" data-pltdoc="x">even?</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"hooray"</span><span class="RktPn">)</span><span class="RktVal">)</span></td></tr><tr><td><p><span class="RktRes">'(#<void>)</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktVal">`</span><span class="RktVal">(</span><span class="RktRdr">,@</span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Flist..rkt%29._when%2Fsplice%29%29" class="RktStxLink" data-pltdoc="x">when/splice</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._even~3f%29%29" class="RktValLink" data-pltdoc="x">even?</a></span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"hooray"</span><span class="RktPn">)</span><span class="RktVal">)</span></td></tr><tr><td><p><span class="RktRes">'("hooray")</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktVal">`</span><span class="RktVal">(</span><span class="RktRdr">,@</span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Flist..rkt%29._when%2Fsplice%29%29" class="RktStxLink" data-pltdoc="x">when/splice</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._even~3f%29%29" class="RktValLink" data-pltdoc="x">even?</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"hooray"</span><span class="RktPn">)</span><span class="RktVal">)</span></td></tr><tr><td><p><span class="RktRes">'()</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._sugar/list..rkt)._values-~3elist))"></a><span title="Provided from: sugar/list | Package: sugar"><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Flist..rkt%29._values-~3elist%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">values->list</a></span></span><span class="hspace"> </span><span class="RktVar">values</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Convert <span class="RktVar">values</span> to a simple list.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._split-at%29%29" class="RktValLink" data-pltdoc="x">split-at</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktRes">'(a b c)</span></p></td></tr><tr><td><p><span class="RktRes">'(d e f)</span></p></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28form._%28%28lib._sugar%2Flist..rkt%29._values-~3elist%29%29" class="RktStxLink" data-pltdoc="x">values->list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._split-at%29%29" class="RktValLink" data-pltdoc="x">split-at</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">b</span><span class="hspace"> </span><span class="RktVal">c</span><span class="hspace"> </span><span class="RktVal">d</span><span class="hspace"> </span><span class="RktVal">e</span><span class="hspace"> </span><span class="RktVal">f</span><span class="RktVal">)</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'((a b c) (d e f))</span></p></td></tr></table></blockquote></td></tr></table></p><h3>8<tt> </tt><a name="(part._.String)"></a><a name="(mod-path._sugar/string)"></a>String</h3><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="index.html#%28mod-path._sugar%2Fstring%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">sugar/string</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">sugar</span></span></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/string..rkt)._starts-with~3f))"></a><span title="Provided from: sugar/string | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._starts-with~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">starts-with?</a></span></span><span class="hspace"> </span><span class="RktVar">str</span><span class="hspace"> </span><span class="RktVar">starter</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">str</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">starter</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return <span class="RktVal">#t</span> if <span class="RktVar">str</span> starts with <span class="RktVar">starter</span>, otherwise <span class="RktVal">#f</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._starts-with~3f%29%29" class="RktValLink" data-pltdoc="x">starts-with?</a></span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="hspace"> </span><span class="RktVal">"foo"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._starts-with~3f%29%29" class="RktValLink" data-pltdoc="x">starts-with?</a></span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._starts-with~3f%29%29" class="RktValLink" data-pltdoc="x">starts-with?</a></span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="hspace"> </span><span class="RktVal">"zam"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._starts-with~3f%29%29" class="RktValLink" data-pltdoc="x">starts-with?</a></span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="hspace"> </span><span class="RktVal">"foobars"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/string..rkt)._ends-with~3f))"></a><span title="Provided from: sugar/string | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._ends-with~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">ends-with?</a></span></span><span class="hspace"> </span><span class="RktVar">str</span><span class="hspace"> </span><span class="RktVar">ender</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">str</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">ender</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return <span class="RktVal">#t</span> if <span class="RktVar">str</span> ends with <span class="RktVar">ender</span>, otherwise <span class="RktVal">#f</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._ends-with~3f%29%29" class="RktValLink" data-pltdoc="x">ends-with?</a></span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="hspace"> </span><span class="RktVal">"foo"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._ends-with~3f%29%29" class="RktValLink" data-pltdoc="x">ends-with?</a></span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._ends-with~3f%29%29" class="RktValLink" data-pltdoc="x">ends-with?</a></span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="hspace"> </span><span class="RktVal">"zam"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._ends-with~3f%29%29" class="RktValLink" data-pltdoc="x">ends-with?</a></span><span class="hspace"> </span><span class="RktVal">"foobar"</span><span class="hspace"> </span><span class="RktVal">"foobars"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/string..rkt)._capitalized~3f))"></a><span title="Provided from: sugar/string | Package: sugar"><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._capitalized~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">capitalized?</a></span></span><span class="hspace"> </span><span class="RktVar">str</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">str</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._stringish~3f%29%29" class="RktValLink" data-pltdoc="x">stringish?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return <span class="RktVal">#t</span> if <span class="RktVar">str</span> starts with a capital letter, otherwise <span class="RktVal">#f</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._capitalized~3f%29%29" class="RktValLink" data-pltdoc="x">capitalized?</a></span><span class="hspace"> </span><span class="RktVal">"Brennan"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._capitalized~3f%29%29" class="RktValLink" data-pltdoc="x">capitalized?</a></span><span class="hspace"> </span><span class="RktVal">"Brennan stinks"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="index.html#%28def._%28%28lib._sugar%2Fstring..rkt%29._capitalized~3f%29%29" class="RktValLink" data-pltdoc="x">capitalized?</a></span><span class="hspace"> </span><span class="RktVal">"stinks"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote></td></tr></table></p><h3>9<tt> </tt><a name="(part._.License___source_code)"></a>License & source code</h3><p>This module is licensed under the LGPL.</p><p>Source repository at <a href="http://github.com/mbutterick/sugar">http://github.com/mbutterick/sugar</a>. Suggestions & corrections welcome.</p></div></div><div id="contextindicator"> </div></body></html> |