/usr/share/doc/racket/unstable/contract.html is in racket-doc 6.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <!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>4 Contracts</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"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-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="tocviewlink" data-pltdoc="x">Unstable:<span class="mywbr"> </span> May Change Without Warning</a></td></tr></table></div><div class="tocviewsublistonly" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="guidelines.html" class="tocviewlink" data-pltdoc="x">Guidelines for Developing <span class="RktSym">unstable</span> Libraries</a></td></tr><tr><td align="right">2 </td><td><a href="Automata__Compiling_State_Machines.html" class="tocviewlink" data-pltdoc="x">Automata:<span class="mywbr"> </span> Compiling State Machines</a></td></tr><tr><td align="right">3 </td><td><a href="bytes.html" class="tocviewlink" data-pltdoc="x">Bytes</a></td></tr><tr><td align="right">4 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">5 </td><td><a href="wrapc.html" class="tocviewlink" data-pltdoc="x">Contracts for Macro Subexpressions</a></td></tr><tr><td align="right">6 </td><td><a href="Debugging.html" class="tocviewlink" data-pltdoc="x">Debugging</a></td></tr><tr><td align="right">7 </td><td><a href="Definitions.html" class="tocviewlink" data-pltdoc="x">Definitions</a></td></tr><tr><td align="right">8 </td><td><a href="error.html" class="tocviewlink" data-pltdoc="x">Errors</a></td></tr><tr><td align="right">9 </td><td><a href="future.html" class="tocviewlink" data-pltdoc="x">Futures</a></td></tr><tr><td align="right">10 </td><td><a href="Functions.html" class="tocviewlink" data-pltdoc="x">Functions</a></td></tr><tr><td align="right">11 </td><td><a href="Hash_Tables.html" class="tocviewlink" data-pltdoc="x">Hash Tables</a></td></tr><tr><td align="right">12 </td><td><a href="class-iop.html" class="tocviewlink" data-pltdoc="x">Interface-<wbr></wbr>Oriented Programming for Classes</a></td></tr><tr><td align="right">13 </td><td><a href="lazy-require.html" class="tocviewlink" data-pltdoc="x">Lazy Require</a></td></tr><tr><td align="right">14 </td><td><a href="list.html" class="tocviewlink" data-pltdoc="x">Lists</a></td></tr><tr><td align="right">15 </td><td><a href="Logging.html" class="tocviewlink" data-pltdoc="x">Logging</a></td></tr><tr><td align="right">16 </td><td><a href="macro-testing.html" class="tocviewlink" data-pltdoc="x">Macro Testing</a></td></tr><tr><td align="right">17 </td><td><a href="Mark_Parameters.html" class="tocviewlink" data-pltdoc="x">Mark Parameters</a></td></tr><tr><td align="right">18 </td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Match</a></td></tr><tr><td align="right">19 </td><td><a href="open-place.html" class="tocviewlink" data-pltdoc="x">Open <span class="RktSym"><span class="RktStxLink">place</span></span> expressions</a></td></tr><tr><td align="right">20 </td><td><a href="options.html" class="tocviewlink" data-pltdoc="x">Option Contracts</a></td></tr><tr><td align="right">21 </td><td><a href="Parameter_Groups.html" class="tocviewlink" data-pltdoc="x">Parameter Groups</a></td></tr><tr><td align="right">22 </td><td><a href="Pretty-Printing.html" class="tocviewlink" data-pltdoc="x">Pretty-<wbr></wbr>Printing</a></td></tr><tr><td align="right">23 </td><td><a href="recontract.html" class="tocviewlink" data-pltdoc="x">Re-<wbr></wbr>Contracting Identifiers</a></td></tr><tr><td align="right">24 </td><td><a href="sandbox.html" class="tocviewlink" data-pltdoc="x">Sandbox</a></td></tr><tr><td align="right">25 </td><td><a href="sequence.html" class="tocviewlink" data-pltdoc="x">Sequences</a></td></tr><tr><td align="right">26 </td><td><a href="string.html" class="tocviewlink" data-pltdoc="x">Strings</a></td></tr><tr><td align="right">27 </td><td><a href="struct.html" class="tocviewlink" data-pltdoc="x">Structs</a></td></tr><tr><td align="right">28 </td><td><a href="custom-write.html" class="tocviewlink" data-pltdoc="x">Struct Printing</a></td></tr><tr><td align="right">29 </td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntax</a></td></tr><tr><td align="right">30 </td><td><a href="temp-c.html" class="tocviewlink" data-pltdoc="x">Temporal Contracts:<span class="mywbr"> </span> Explicit Contract Monitors</a></td></tr><tr><td align="right">31 </td><td><a href="unix-socket.html" class="tocviewlink" data-pltdoc="x">Unix Domain Sockets</a></td></tr><tr><td align="right">32 </td><td><a href="2d.html" class="tocviewlink" data-pltdoc="x">2D Syntax</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._non-empty-string~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">non-<wbr></wbr>empty-<wbr></wbr>string?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._port-number~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">port-<wbr></wbr>number?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._tcp-listen-port~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">tcp-<wbr></wbr>listen-<wbr></wbr>port?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._path-piece~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">path-<wbr></wbr>piece?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._if%2Fc%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">if/<span class="mywbr"> </span>c</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._failure-result%2Fc%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">failure-<wbr></wbr>result/<span class="mywbr"> </span>c</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._rename-contract%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">rename-<wbr></wbr>contract</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._maybe%2Fc%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">maybe/<span class="mywbr"> </span>c</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._truth%2Fc%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">truth/<span class="mywbr"> </span>c</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._sequence%2Fc%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">sequence/<span class="mywbr"> </span>c</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._treeof%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">treeof</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.1</span></div><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="bytes.html" title="backward to "3 Bytes"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Unstable: May Change Without Warning"" data-pltdoc="x">up</a> <a href="wrapc.html" title="forward to "5 Contracts for Macro Subexpressions"" data-pltdoc="x">next →</a></span> </div><h3 x-source-module="(lib "unstable/scribblings/unstable.scrbl")" x-part-tag=""contract"">4<tt> </tt><a name="(part._contract)"></a><a name="(mod-path._unstable/contract)"></a>Contracts</h3><p>This library is <span style="font-style: italic">unstable</span>;
compatibility will not be maintained.
See <a href="index.html" data-pltdoc="x">Unstable: May Change Without Warning</a>
for more information.</p><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left" colspan="2"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=require.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._require%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">unstable/contract</span></a><span class="RktPn">)</span></td></tr><tr><td align="left"> </td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">unstable-contract-lib</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._unstable/contract..rkt)._non-empty-string~3f))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._non-empty-string~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">non-empty-string?</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</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="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">x</span> is a string and is not empty;
returns <span class="RktVal">#f</span> otherwise.</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>value</p></div></div><p class="RForeground"><a name="(def._((lib._unstable/contract..rkt)._port-number~3f))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._port-number~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">port-number?</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Equivalent to <span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._between%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">between/c</a></span><span class="stt"> </span><span class="RktVal">1</span><span class="stt"> </span><span class="RktVal">65535</span><span class="RktPn">)</span>.</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>value</p></div></div><p class="RForeground"><a name="(def._((lib._unstable/contract..rkt)._tcp-listen-port~3f))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._tcp-listen-port~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">tcp-listen-port?</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Equivalent to <span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._between%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">between/c</a></span><span class="stt"> </span><span class="RktVal">0</span><span class="stt"> </span><span class="RktVal">65535</span><span class="RktPn">)</span>.</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>value</p></div></div><p class="RForeground"><a name="(def._((lib._unstable/contract..rkt)._path-piece~3f))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._path-piece~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">path-piece?</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Equivalent to <span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="stt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Manipulating_Paths.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fmisc..rkt%2529._path-string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">path-string?</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._symbols%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">symbols</a></span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">up</span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">same</span><span class="RktPn">)</span><span class="RktPn">)</span>.</div></p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>The subsequent bindings were added by Ryan Culpepper.</p></blockquote></blockquote></blockquote><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._unstable/contract..rkt)._if/c))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._if%2Fc%29%29" class="RktValDef RktValLink" data-pltdoc="x">if/c</a></span></span><span class="hspace"> </span><span class="RktVar">predicate</span><span class="hspace"> </span><span class="RktVar">then-contract</span><span class="hspace"> </span><span class="RktVar">else-contract</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">predicate</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">then-contract</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">else-contract</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Produces a contract that, when applied to a value, first tests the
value with <span class="RktVar">predicate</span>; if <span class="RktVar">predicate</span> returns true, the
<span class="RktVar">then-contract</span> is applied; otherwise, the
<span class="RktVar">else-contract</span> is applied. The resulting contract is a flat
contract if both <span class="RktVar">then-contract</span> and <span class="RktVar">else-contract</span> are
flat contracts.</div></p><p><div class="SIntrapara">For example, the following contract enforces that if a value is a
procedure, it is a thunk; otherwise it can be any (non-procedure)
value:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._if%2Fc%29%29" class="RktValLink" data-pltdoc="x">if/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=procedures.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._procedure%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">procedure?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">any</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span></p></blockquote></div><div class="SIntrapara">Note that the following contract is <span style="font-weight: bold">not</span> equivalent:
</div><div class="SIntrapara"><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">any</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="RktCmt">wrong!</span></p></blockquote></div><div class="SIntrapara">The last contract is the same as <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span> because
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">or/c</a></span> tries flat contracts before higher-order contracts.</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>value</p></div></div><p class="RForeground"><a name="(def._((lib._unstable/contract..rkt)._failure-result/c))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._failure-result%2Fc%29%29" class="RktValDef RktValLink" data-pltdoc="x">failure-result/c</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A contract that describes the failure result arguments of procedures
such as <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=hashtables.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._hash-ref%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">hash-ref</a></span>.</div></p><p>Equivalent to <span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._if%2Fc%29%29" class="RktValLink" data-pltdoc="x">if/c</a></span><span class="stt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=procedures.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._procedure%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">procedure?</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="stt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">any</a></span><span class="RktPn">)</span><span class="stt"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="RktPn">)</span>.</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._unstable/contract..rkt)._rename-contract))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._rename-contract%29%29" class="RktValDef RktValLink" data-pltdoc="x">rename-contract</a></span></span><span class="hspace"> </span><span class="RktVar">contract</span><span class="hspace"> </span><span class="RktVar">name</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">contract</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">name</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Produces a contract that acts like <span class="RktVar">contract</span> but with the name
<span class="RktVar">name</span>.</div></p><p>The resulting contract is a flat contract if <span class="RktVar">contract</span> is a
flat contract.</p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>The subsequent bindings were added by Asumu Takikawa.</p></blockquote></blockquote></blockquote><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._unstable/contract..rkt)._maybe/c))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._maybe%2Fc%29%29" class="RktValDef RktValLink" data-pltdoc="x">maybe/c</a></span></span><span class="hspace"> </span><span class="RktVar">contract</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">contract</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Creates a contract that acts like <span class="RktVar">contract</span> but will also
accept <span class="RktVal">#f</span>. Intended to describe situations where a failure
or default value may be used.</div></p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>The subsequent bindings were added by Carl Eastlund <<a href="mailto:cce@racket-lang.org">cce@racket-lang.org</a>>.</p></blockquote></blockquote></blockquote><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>value</p></div></div><p class="RForeground"><a name="(def._((lib._unstable/contract..rkt)._truth/c))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._truth%2Fc%29%29" class="RktValDef RktValLink" data-pltdoc="x">truth/c</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._flat-contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">flat-contract?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">This contract recognizes Racket truth values, i.e., any value, but with a more
informative name and description. Use it in negative positions for arguments
that accept arbitrary truth values that may not be booleans.</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><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td><span class="RktPn">(</span><a name="(def._((lib._unstable/contract..rkt)._sequence/c))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._sequence%2Fc%29%29" class="RktValDef RktValLink" data-pltdoc="x">sequence/c</a></span></span></td><td><span class="hspace"> </span>[</td><td><span class="RktPn">#:min-count</span><span class="hspace"> </span><span class="RktVar">min-count</span>]</td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td></tr><tr><td><span class="hspace"> </span></td><td><span class="hspace"> </span></td><td><span class="RktVar">elem/c</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td><td><span class="hspace"> </span></td><td>→</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">min-count</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._or%252Fc%2529%2529&version=6.1" class="RktValLink Sq" 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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._exact-nonnegative-integer%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="RktPn">)</span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktVal">#f</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">elem/c</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Wraps a <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=sequences.html%23%2528tech._sequence%2529&version=6.1" class="techoutside Sq" data-pltdoc="x"><span class="techinside">sequence</span></a>,
obligating it to produce as many values as there are <span class="RktVar">elem/c</span> contracts,
and obligating each value to satisfy the corresponding <span class="RktVar">elem/c</span>. The
result is not guaranteed to be the same kind of sequence as the original value;
for instance, a wrapped list is not guaranteed to satisfy <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list?</a></span>.</div></p><p>If <span class="RktVar">min-count</span> is a number, the stream is required to have at least that many elements in it.</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=attaching-contracts-to-values.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fregion..rkt%2529._define%252Fcontract%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">define/contract</a></span><span class="hspace"> </span><span class="RktSym">predicates</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._sequence%2Fc%29%29" class="RktValLink" data-pltdoc="x">sequence/c</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=function-contracts.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fbase..rkt%2529._-%7E3e%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._any%252Fc%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._boolean%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">boolean?</a></span><span class="RktPn">)</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=sequences.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._in-list%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">in-list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._integer%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">integer?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string-%7E3esymbol%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string->symbol</a></span><span class="RktPn">)</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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=for.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._for%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">for</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">P</span><span class="hspace"> </span><span class="RktSym">predicates</span><span class="RktPn">]</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Writing.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._printf%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">printf</a></span><span class="hspace"> </span><span class="RktVal">"~s\n"</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">P</span><span class="hspace"> </span><span class="RktVal">"cat"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktOut">#f</span></p></td></tr><tr><td><p><span class="RktErr">predicates: broke its contract</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">promised: boolean?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">produced: 'cat</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">in: the range of</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">an element of</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(sequence/c (-> any/c boolean?))</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">contract from: (definition predicates)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">blaming: (definition predicates)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">at: eval:2.0</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=attaching-contracts-to-values.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fregion..rkt%2529._define%252Fcontract%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">define/contract</a></span><span class="hspace"> </span><span class="RktSym">numbers&strings</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._sequence%2Fc%29%29" class="RktValLink" data-pltdoc="x">sequence/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._number%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">number?</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=dicts.html%23%2528def._%2528%2528lib._racket%252Fdict..rkt%2529._in-dict%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">in-dict</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">"one"</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">"two"</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">three</span><span class="RktPn">)</span><span class="RktPn">)</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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=for.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._for%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">for</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">N</span><span class="hspace"> </span><span class="RktSym">S</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">numbers&strings</span><span class="RktPn">]</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Writing.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._printf%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">printf</a></span><span class="hspace"> </span><span class="RktVal">"~s: ~a\n"</span><span class="hspace"> </span><span class="RktSym">N</span><span class="hspace"> </span><span class="RktSym">S</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktOut">1: one</span></p></td></tr><tr><td><p><span class="RktOut">2: two</span></p></td></tr></table></td></tr><tr><td><p><span class="RktErr">numbers&strings: broke its contract</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">promised: string?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">produced: 'three</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">in: an element of</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(sequence/c number? string?)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">contract from: (definition numbers&strings)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">blaming: (definition numbers&strings)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">at: eval:4.0</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=attaching-contracts-to-values.html%23%2528form._%2528%2528lib._racket%252Fcontract%252Fregion..rkt%2529._define%252Fcontract%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">define/contract</a></span><span class="hspace"> </span><span class="RktSym">a-sequence</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._sequence%2Fc%29%29" class="RktValLink" data-pltdoc="x">sequence/c</a></span><span class="hspace"> </span><span class="RktPn">#:min-count</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=characters.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._char%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">char?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">"x"</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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=for.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._for%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">for</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">a-sequence</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=sequences.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._in-naturals%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">in-naturals</a></span><span class="RktPn">)</span><span class="RktPn">]</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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=Writing.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._printf%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">printf</a></span><span class="hspace"> </span><span class="RktVal">"~a is ~a\n"</span><span class="hspace"> </span><span class="RktSym">i</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktOut">0 is x</span></p></td></tr><tr><td><p><span class="RktErr">a-sequence: broke its contract</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">promised: a sequence that contains at least 2 values</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">produced: "x"</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">in: (sequence/c #:min-count 2 char?)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">contract from: (definition a-sequence)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">blaming: (definition a-sequence)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">at: eval:6.0</span></p></td></tr></table></blockquote></td></tr></table></p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>The subsequent bindings were added by Neil Toronto <<a href="mailto:neil.toronto@gmail.com">neil.toronto@gmail.com</a>>.</p></blockquote></blockquote></blockquote><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._unstable/contract..rkt)._treeof))"></a><span title="Provided from: unstable/contract | Package: unstable-contract-lib"><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._treeof%29%29" class="RktValDef RktValLink" data-pltdoc="x">treeof</a></span></span><span class="hspace"> </span><span class="RktVar">elem-contract</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">elem-contract</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">contract?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Identifies values that meet the contract <span class="RktVar">elem-contract</span>, lists of such values, lists of lists, and so on.
</div><div class="SIntrapara"><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://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">number-tree/c</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._unstable%2Fcontract..rkt%29._treeof%29%29" class="RktValLink" data-pltdoc="x">treeof</a></span><span class="hspace"> </span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._number%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">number?</a></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="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=contract-utilities.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._flat-contract%7E3f%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">flat-contract?</a></span><span class="hspace"> </span><span class="RktSym">number-tree/c</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="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">number-tree?</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&rel=data-structure-contracts.html%23%2528def._%2528%2528lib._racket%252Fcontract%252Fprivate%252Fmisc..rkt%2529._flat-contract-predicate%2529%2529&version=6.1" class="RktValLink Sq" data-pltdoc="x">flat-contract-predicate</a></span><span class="hspace"> </span><span class="RktSym">number-tree/c</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="RktPn">(</span><span class="RktSym">number-tree?</span><span class="hspace"> </span><span class="RktVal">4</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">number-tree?</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</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">number-tree?</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">(</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">6</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">number-tree?</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">4</span><span class="hspace"> </span><span class="RktVal">. </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></table></blockquote></td></tr></table></div></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="bytes.html" title="backward to "3 Bytes"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Unstable: May Change Without Warning"" data-pltdoc="x">up</a> <a href="wrapc.html" title="forward to "5 Contracts for Macro Subexpressions"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|