</div><divclass="SIntrapara"><tablecellspacing="0"cellpadding="0"><tr><td><p><spanclass="stt">raco pkg install sugar</span></p></td></tr></table></div></p><p><divclass="SIntrapara">After that, you can update the package from the command line:
</div><divclass="SIntrapara"><tablecellspacing="0"cellpadding="0"><tr><td><p><spanclass="stt">raco pkg update sugar</span></p></td></tr></table></div></p><h3>2<tt> </tt><aname="(part._.Coercion)"></a><aname="(mod-path._sugar/coerce)"></a>Coercion</h3><p><tablecellspacing="0"cellpadding="0"class="defmodule"><tr><tdalign="left"><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="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><spanclass="stt"></span><ahref="#%28mod-path._sugar%2Fcoerce%29"class="RktModLink"data-pltdoc="x"><spanclass="RktSym">sugar/coerce</span></a><spanclass="RktPn">)</span></td><tdalign="right"><spanclass="RpackageSpec"><spanclass="Smaller"> package:</span><spanclass="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><aname="(part._.Values)"></a>Values</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"cellpadding="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._sugar/coerce..rkt)._-~3eint))"></a><spantitle="Provided from: sugar/coerce | Package: sugar"><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29"class="RktValDef RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>int</a></span></span><spanclass="hspace"> </span><spanclass="RktVar">v</span><spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="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><spanclass="hspace"> </span><spanclass="RktVar">v</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="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><divclass="SIntrapara">Convert <spanclass="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><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquoteclass="SCodeFlow"><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>int</a></span><spanclass="hspace"> </span><spanclass="RktVal">3</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktRes">3</span></p></td></tr><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>int</a></span><spanclass="hspace"> </span><spanclass="RktVal">3.5</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktRes">3</span></p></td></tr><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29"class="RktValLink"data-pltdoc
</div><divclass="SIntrapara"><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquoteclass="SCodeFlow"><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>int</a></span><spanclass="hspace"> </span><spanclass="RktVal">#t</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktErr">Can’t convert #t to integer</span></p></td></tr></table></blockquote></td></tr></table></div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"cellpadding="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._sugar/coerce..rkt)._-~3estring))"></a><spantitle="Provided from: sugar/coerce | Package: sugar"><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValDef RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span></span><spanclass="hspace"> </span><spanclass="RktVar">v</span><spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="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><spanclass="hspace"> </span><spanclass="RktVar">v</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="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><divclass="SIntrapara">Return the most natural string representation of <spanclass="RktVar">v</span>, or raise an error if none exists.</div></p><p><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquoteclass="SCodeFlow"><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span><spanclass="hspace"> </span><spanclass="RktVal">"string"</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktRes">"string"</span></p></td></tr><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">symbol</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktRes">"symbol"</span></p></td></tr><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span><spanclass="hspace"> </span><spanclass="RktVal">98.6</span><spanclass="RktPn">)</span></td></tr><tr><td><p><spanclass="RktRes">"98.6"</span></p></td></tr><tr><td><spanclass="stt">></span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29"class="RktValLink"data-pltdoc="x"><spanclass="nobreak">-></span>string</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/Manipulating_Paths.html#%28def._%
<br/>(first-condition? x) = #t</span></p><p>But be careful — in the example below, the result of the <spanclass="RktSym"><ahref="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 <spanclass="RktVar">x</span>:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"cellpadding="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="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><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="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><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29"class="RktStxLink"data-pltdoc="x">report</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">first-condition?</span><spanclass="hspace"> </span><spanclass="RktSym">x</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">second-condition?</span><spanclass="hspace"> </span><spanclass="RktSym">x</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">one-thing</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">other-thing</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="#%28form._%28%28lib._sugar%2Fdebug..rkt%29._report%29%29"class="RktStxLink"data-pltdoc="x">report</a></span><spanclass="hspace"> </span><spanclass="RktSym">x</span><spanclass="RktPn">)</span></td></tr></table></blockquote><h3>5<tt> </tt><aname="(part._.File)"></a><aname="(mod-path._sugar/file)"></a>File</h3><p><tablecellspacing="0"cellpadding="0"class="defmodule"><tr><tdalign="left"><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="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><spanclass="stt"></span><ahref="#%28mod-path._sugar%2Ffile%29"class="RktModLink"data-pltdoc="x"><spanclass="RktSym">sugar/file</span></a><spanclass="RktPn">)</span></td><tdalign="right"><spanclass="RpackageSpec"><spanclass="Smaller"> package:</span><spanclass="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 <spanclass="RktSym"><ahref="#%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><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"cellpadding="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._sugar/file..rkt)._get-ext))"></a><spantitle="Provided from: sugar/file | Package: sugar"><spanclass="RktSym"><ahref="#%28def._%28%28lib._sugar%2Ffile..rkt%29._get-ext%29%29"class="RktValDef RktValLink"data-pltdoc="x">get-ext</a></span></span><spanclass="hspace"> </span><spanclass="RktVar">file-path</span><spanclass="RktPn">)</sp