<div dir="ltr"><div>I encountered the following error — imagine a function that returns 3.0 instead of just 3.0 as shown example below:</div><div><br></div><div><font face="courier new, monospace">> (split-at-right (range 8) 3.0)</font></div>
<div><font face="courier new, monospace">split-at-right: contract violation</font></div><div><font face="courier new, monospace"> expected: exact-nonnegative-integer?</font></div><div><font face="courier new, monospace"> given: 3.0</font></div>
<div><font face="courier new, monospace"> context...:</font></div><div><font face="courier new, monospace"> /Applications/Racket/collects/racket/list.rkt:191:0: split-at-right</font></div><div><font face="courier new, monospace"> /Applications/Racket/collects/racket/private/misc.rkt:87:7</font></div>
<div><br></div><div>The obvious fixes didn't work ...</div><div><br></div><div><font face="courier new, monospace">> (split-at-right (range 8) (round 3.0))</font></div><div><font face="courier new, monospace">split-at-right: contract violation</font></div>
<div><font face="courier new, monospace"> expected: exact-nonnegative-integer?</font></div><div><font face="courier new, monospace"> given: 3.0</font></div><div><font face="courier new, monospace"> context...:</font></div>
<div><font face="courier new, monospace"> /Applications/Racket/collects/racket/list.rkt:191:0: split-at-right</font></div><div><font face="courier new, monospace"> /Applications/Racket/collects/racket/private/misc.rkt:87:7</font></div>
<div><font face="courier new, monospace">> </font></div><div><br></div><div>... and I couldn't find something like real->integer, but inexact->exact came to the rescue: </div><div><br></div><div><div><font face="courier new, monospace">> (split-at-right (range 8) (inexact->exact 3.0))</font></div>
<div><font face="courier new, monospace">(split-at-right (range 8) (inexact->exact 3.0))</font></div><div><font face="courier new, monospace">'(0 1 2 3 4)</font></div><div><font face="courier new, monospace">'(5 6 7)</font></div>
<div><font face="courier new, monospace">> (split-at-right (range 8) 3.0)</font></div><div><font face="courier new, monospace">split-at-right: contract violation</font></div><div><font face="courier new, monospace"> expected: exact-nonnegative-integer?</font></div>
<div><font face="courier new, monospace"> given: 3.0</font></div><div><font face="courier new, monospace"> context...:</font></div><div><font face="courier new, monospace"> /Applications/Racket/collects/racket/list.rkt:191:0: split-at-right</font></div>
<div><font face="courier new, monospace"> /Applications/Racket/collects/racket/private/misc.rkt:87:7</font></div><div><font face="courier new, monospace">></font></div></div><div><br></div><div>Still, it doesn't seem particularly elegant.</div>
<div><br></div></div>