123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542 |
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <!-- This file is generated by Nim. -->
- <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>std/ropes</title>
- <!-- Google fonts -->
- <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
- <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
- <!-- Favicon -->
- <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
- <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
- <!-- CSS -->
- <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
- <!-- JS -->
- <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
- </head>
- <body>
- <div class="document" id="documentId">
- <div class="container">
- <h1 class="title">std/ropes</h1>
- <div class="row">
- <div class="three columns">
- <div class="theme-select-wrapper">
- <label for="theme-select">Theme: </label>
- <select id="theme-select" onchange="setTheme(this.value)">
- <option value="auto">🌗 Match OS</option>
- <option value="dark">🌑 Dark</option>
- <option value="light">🌕 Light</option>
- </select>
- </div>
- <div id="global-links">
- <ul class="simple-boot">
- <li><a href="manual.html">Manual</a></li>
- <li><a href="lib.html">Standard library</a></li>
- <li> <a id="indexLink" href="theindex.html">Index</a></li>
- <li><a href="compiler/theindex.html">Compiler docs</a></li>
- <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
- <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
- </ul>
- </div>
- <div id="searchInputDiv">
- Search: <input type="search" id="searchInput"
- oninput="search()" />
- </div>
-
- <ul class="simple simple-toc" id="toc-list">
- <li>
- <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
- <ul class="simple simple-toc-section">
- <li><a class="reference" href="#Rope" title="Rope {.acyclic.} = ref object">Rope</a></li>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">$
- <li><a class="reference" href="#%24%2CRope" title="`$`(r: Rope): string">`$`(r: Rope): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">%
- <li><a class="reference" href="#%25%2Cstring%2CopenArray%5BRope%5D" title="`%`(frmt: string; args: openArray[Rope]): Rope">`%`(frmt: string; args: openArray[Rope]): Rope</a></li>
- </ul>
- <ul class="simple nested-toc-section">&
- <li><a class="reference" href="#%26%2CRope%2CRope" title="`&`(a, b: Rope): Rope">`&`(a, b: Rope): Rope</a></li>
- <li><a class="reference" href="#%26%2CopenArray%5BRope%5D" title="`&`(a: openArray[Rope]): Rope">`&`(a: openArray[Rope]): Rope</a></li>
- <li><a class="reference" href="#%26%2CRope%2Cstring" title="`&`(a: Rope; b: string): Rope">`&`(a: Rope; b: string): Rope</a></li>
- <li><a class="reference" href="#%26%2Cstring%2CRope" title="`&`(a: string; b: Rope): Rope">`&`(a: string; b: Rope): Rope</a></li>
- </ul>
- <ul class="simple nested-toc-section">[]
- <li><a class="reference" href="#%5B%5D%2CRope%2Cint" title="`[]`(r: Rope; i: int): char">`[]`(r: Rope; i: int): char</a></li>
- </ul>
- <ul class="simple nested-toc-section">add
- <li><a class="reference" href="#add%2CRope%2CRope" title="add(a: var Rope; b: Rope)">add(a: var Rope; b: Rope)</a></li>
- <li><a class="reference" href="#add%2CRope%2Cstring" title="add(a: var Rope; b: string)">add(a: var Rope; b: string)</a></li>
- </ul>
- <ul class="simple nested-toc-section">addf
- <li><a class="reference" href="#addf%2CRope%2Cstring%2CopenArray%5BRope%5D" title="addf(c: var Rope; frmt: string; args: openArray[Rope])">addf(c: var Rope; frmt: string; args: openArray[Rope])</a></li>
- </ul>
- <ul class="simple nested-toc-section">disableCache
- <li><a class="reference" href="#disableCache" title="disableCache()">disableCache()</a></li>
- </ul>
- <ul class="simple nested-toc-section">enableCache
- <li><a class="reference" href="#enableCache" title="enableCache()">enableCache()</a></li>
- </ul>
- <ul class="simple nested-toc-section">equalsFile
- <li><a class="reference" href="#equalsFile%2CRope%2CFile" title="equalsFile(r: Rope; f: File): bool">equalsFile(r: Rope; f: File): bool</a></li>
- <li><a class="reference" href="#equalsFile%2CRope%2Cstring" title="equalsFile(r: Rope; filename: string): bool">equalsFile(r: Rope; filename: string): bool</a></li>
- </ul>
- <ul class="simple nested-toc-section">len
- <li><a class="reference" href="#len%2CRope" title="len(a: Rope): int">len(a: Rope): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">rope
- <li><a class="reference" href="#rope%2CBiggestFloat" title="rope(f: BiggestFloat): Rope">rope(f: BiggestFloat): Rope</a></li>
- <li><a class="reference" href="#rope%2CBiggestInt" title="rope(i: BiggestInt): Rope">rope(i: BiggestInt): Rope</a></li>
- <li><a class="reference" href="#rope%2Cstring" title="rope(s: string = ""): Rope">rope(s: string = ""): Rope</a></li>
- </ul>
- <ul class="simple nested-toc-section">write
- <li><a class="reference" href="#write%2CFile%2CRope" title="write(f: File; r: Rope)">write(f: File; r: Rope)</a></li>
- <li><a class="reference" href="#write%2CStream%2CRope" title="write(s: Stream; r: Rope)">write(s: Stream; r: Rope)</a></li>
- </ul>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">items
- <li><a class="reference" href="#items.i%2CRope" title="items(r: Rope): char">items(r: Rope): char</a></li>
- </ul>
- <ul class="simple nested-toc-section">leaves
- <li><a class="reference" href="#leaves.i%2CRope" title="leaves(r: Rope): string">leaves(r: Rope): string</a></li>
- </ul>
- </ul>
- </details>
- </li>
- </ul>
- </div>
- <div class="nine columns" id="content">
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L1" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
- <div id="tocRoot"></div>
-
- <p class="module-desc">This module contains support for a <span id="rope_1">rope</span> data type. Ropes can represent very long strings efficiently; in particular, concatenation is done in O(1) instead of O(n). They are essentially concatenation trees that are only flattened when converting to a native Nim string. The empty string is represented by <tt class="docutils literal"><span class="pre"><span class="Keyword">nil</span></span></tt>. Ropes are immutable and subtrees can be shared without copying. Leaves can be cached for better memory efficiency at the cost of runtime efficiency.</p>
- <div class="section" id="6">
- <h1><a class="toc-backref" href="#6">Imports</a></h1>
- <dl class="item">
- <a class="reference external" href="streams.html">streams</a>, <a class="reference external" href="syncio.html">syncio</a>, <a class="reference external" href="formatfloat.html">formatfloat</a>, <a class="reference external" href="assertions.html">assertions</a>
- </dl>
- </div>
- <div class="section" id="7">
- <h1><a class="toc-backref" href="#7">Types</a></h1>
- <dl class="item">
- <div id="Rope">
- <dt><pre><a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span class="Identifier">acyclic</span>.} <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span></pre></dt>
- <dd>
-
- A rope data type. The empty rope is represented by <tt class="docutils literal"><span class="pre"><span class="Keyword">nil</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L35" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L35" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </dl>
- </div>
- <div class="section" id="12">
- <h1><a class="toc-backref" href="#12">Procs</a></h1>
- <dl class="item">
- <div id="$-procs-all">
- <div id="$,Rope">
- <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CRope"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nroToString"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Converts a rope back to a string.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L291" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L291" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="%-procs-all">
- <div id="%,string,openArray[Rope]">
- <dt><pre><span class="Keyword">proc</span> <a href="#%25%2Cstring%2CopenArray%5BRope%5D"><span class="Identifier">`%`</span></a><span class="Other">(</span><span class="Identifier">frmt</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
- <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nroFormat"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- <tt class="docutils literal"><span class="pre"><span class="Operator">%</span></span></tt> substitution operator for ropes. Does not support the <tt class="docutils literal"><span class="pre"><span class="Operator">$</span><span class="Identifier">identifier</span></span></tt> nor <tt class="docutils literal"><span class="pre"><span class="Operator">$</span><span class="Punctuation">{</span><span class="Identifier">identifier</span><span class="Punctuation">}</span></span></tt> notations.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r1</span> <span class="Operator">=</span> <span class="StringLit">"$1 $2 $3"</span> <span class="Operator">%</span> <span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Nim"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"is"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"a great language"</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r1</span> <span class="Operator">==</span> <span class="StringLit">"Nim is a great language"</span>
- <span class="Keyword">let</span> <span class="Identifier">r2</span> <span class="Operator">=</span> <span class="StringLit">"$# $# $#"</span> <span class="Operator">%</span> <span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Nim"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"is"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"a great language"</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r2</span> <span class="Operator">==</span> <span class="StringLit">"Nim is a great language"</span>
- <span class="Keyword">let</span> <span class="Identifier">r3</span> <span class="Operator">=</span> <span class="StringLit">"${1} ${2} ${3}"</span> <span class="Operator">%</span> <span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Nim"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"is"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"a great language"</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r3</span> <span class="Operator">==</span> <span class="StringLit">"Nim is a great language"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L296" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L296" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="&-procs-all">
- <div id="&,Rope,Rope">
- <dt><pre><span class="Keyword">proc</span> <a href="#%26%2CRope%2CRope"><span class="Identifier">`&`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nroConcRopeRope"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- The concatenation operator for ropes.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Hello, "</span><span class="Punctuation">)</span> <span class="Operator">&</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Nim!"</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"Hello, Nim!"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L175" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L175" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="&,openArray[Rope]">
- <dt><pre><span class="Keyword">proc</span> <a href="#%26%2CopenArray%5BRope%5D"><span class="Identifier">`&`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nroConcOpenArray"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- The concatenation operator for an <tt class="docutils literal"><span class="pre"><span class="Identifier">openArray</span></span></tt> of ropes.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Operator">&</span><span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Hello, "</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Nim"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"!"</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"Hello, Nim!"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L207" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L207" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="&,Rope,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#%26%2CRope%2Cstring"><span class="Identifier">`&`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nroConcRopeStr"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- The concatenation operator for ropes.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Hello, "</span><span class="Punctuation">)</span> <span class="Operator">&</span> <span class="StringLit">"Nim!"</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"Hello, Nim!"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L191" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L191" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="&,string,Rope">
- <dt><pre><span class="Keyword">proc</span> <a href="#%26%2Cstring%2CRope"><span class="Identifier">`&`</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nroConcStrRope"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- The concatenation operator for ropes.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="StringLit">"Hello, "</span> <span class="Operator">&</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Nim!"</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"Hello, Nim!"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L199" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L199" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="[]-procs-all">
- <div id="[],Rope,int">
- <dt><pre><span class="Keyword">proc</span> <a href="#%5B%5D%2CRope%2Cint"><span class="Identifier">`[]`</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nroCharAt"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Returns the character at position <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt> in the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>. This is quite expensive! Worst-case: O(n). If <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span> <span class="Operator">>=</span> <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">len</span> <span class="Keyword">or</span> <span class="Identifier">i</span> <span class="Operator"><</span> <span class="DecNumber">0</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="DecNumber">0</span></span></tt> is returned.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Hello, Nim!"</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Identifier">r</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="CharLit">'H'</span>
- <span class="Identifier">doAssert</span> <span class="Identifier">r</span><span class="Punctuation">[</span><span class="DecNumber">7</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="CharLit">'N'</span>
- <span class="Identifier">doAssert</span> <span class="Identifier">r</span><span class="Punctuation">[</span><span class="DecNumber">22</span><span class="Punctuation">]</span> <span class="Operator">==</span> <span class="CharLit">'\0'</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L233" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L233" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="add-procs-all">
- <div id="add,Rope,Rope">
- <dt><pre><span class="Keyword">proc</span> <a href="#add%2CRope%2CRope"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1Rope"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Adds <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt> to the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Hello, "</span><span class="Punctuation">)</span>
- <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Nim!"</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"Hello, Nim!"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L215" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L215" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="add,Rope,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#add%2CRope%2Cstring"><span class="Identifier">add</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1Str"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Adds <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt> to the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Hello, "</span><span class="Punctuation">)</span>
- <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="StringLit">"Nim!"</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"Hello, Nim!"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L224" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L224" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="addf-procs-all">
- <div id="addf,Rope,string,openArray[Rope]">
- <dt><pre><span class="Keyword">proc</span> <a href="#addf%2CRope%2Cstring%2CopenArray%5BRope%5D"><span class="Identifier">addf</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">frmt</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">args</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
- <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Shortcut for <tt class="docutils literal"><span class="pre"><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="Identifier">frmt</span> <span class="Operator">%</span> <span class="Identifier">args</span><span class="Punctuation">)</span></span></tt>.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">var</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Dash: "</span><span class="Punctuation">)</span>
- <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">addf</span> <span class="StringLit">"$1 $2 $3"</span><span class="Punctuation">,</span> <span class="Punctuation">[</span><span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Nim"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"is"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"a great language"</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"Dash: Nim is a great language"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L349" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L349" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="disableCache-procs-all">
- <div id="disableCache">
- <dt><pre><span class="Keyword">proc</span> <a href="#disableCache"><span class="Identifier">disableCache</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- The cache is discarded and disabled. The GC will reuse its used memory.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L170" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L170" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="enableCache-procs-all">
- <div id="enableCache">
- <dt><pre><span class="Keyword">proc</span> <a href="#enableCache"><span class="Identifier">enableCache</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Enables the caching of leaves. This reduces the memory footprint at the cost of runtime efficiency.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L165" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L165" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="equalsFile-procs-all">
- <div id="equalsFile,Rope,File">
- <dt><pre><span class="Keyword">proc</span> <a href="#equalsFile%2CRope%2CFile"><span class="Identifier">equalsFile</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1File"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Returns true if the contents of the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> equal <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L362" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L362" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="equalsFile,Rope,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#equalsFile%2CRope%2Cstring"><span class="Identifier">equalsFile</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1Str"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Returns true if the contents of the file <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> equal <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>. If <tt class="docutils literal"><span class="pre"><span class="Identifier">f</span></span></tt> does not exist, false is returned.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L389" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L389" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="len-procs-all">
- <div id="len,Rope">
- <dt><pre><span class="Keyword">proc</span> <a href="#len%2CRope"><span class="Identifier">len</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- The rope's length.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L49" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L49" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="rope-procs-all">
- <div id="rope,BiggestFloat">
- <dt><pre><span class="Keyword">proc</span> <a href="#rope%2CBiggestFloat"><span class="Identifier">rope</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="ctypes.html#BiggestFloat"><span class="Identifier">BiggestFloat</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1BiggestFloat"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Converts a float to a rope.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="FloatNumber">4.29</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"4.29"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L157" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L157" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="rope,BiggestInt">
- <dt><pre><span class="Keyword">proc</span> <a href="#rope%2CBiggestInt"><span class="Identifier">rope</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="ctypes.html#BiggestInt"><span class="Identifier">BiggestInt</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1BiggestInt"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Converts an int to a rope.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="DecNumber">429</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"429"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L149" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L149" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="rope,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#rope%2Cstring"><span class="Identifier">rope</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1Str"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Converts a string to a rope.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"I'm a rope"</span><span class="Punctuation">)</span>
- <span class="Identifier">doAssert</span> <span class="Operator">$</span><span class="Identifier">r</span> <span class="Operator">==</span> <span class="StringLit">"I'm a rope"</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L130" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L130" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="write-procs-all">
- <div id="write,File,Rope">
- <dt><pre><span class="Keyword">proc</span> <a href="#write%2CFile%2CRope"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="syncio.html#File"><span class="Identifier">File</span></a><span class="Other">;</span> <span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nro$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Writes a rope to a file.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L283" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L283" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="write,Stream,Rope">
- <dt><pre><span class="Keyword">proc</span> <a href="#write%2CStream%2CRope"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="streams.html#Stream"><span class="Identifier">Stream</span></a><span class="Other">;</span> <span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nroWriteStream"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Writes a rope to a stream.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L287" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L287" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- <div class="section" id="15">
- <h1><a class="toc-backref" href="#15">Iterators</a></h1>
- <dl class="item">
- <div id="items-iterators-all">
- <div id="items.i,Rope">
- <dt><pre><span class="Keyword">iterator</span> <a href="#items.i%2CRope"><span class="Identifier">items</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#char"><span class="Identifier">char</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Iterates over any character in the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L278" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L278" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="leaves-iterators-all">
- <div id="leaves.i,Rope">
- <dt><pre><span class="Keyword">iterator</span> <a href="#leaves.i%2CRope"><span class="Identifier">leaves</span></a><span class="Other">(</span><span class="Identifier">r</span><span class="Other">:</span> <a href="ropes.html#Rope"><span class="Identifier">Rope</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Iterates over any leaf string in the rope <tt class="docutils literal"><span class="pre"><span class="Identifier">r</span></span></tt>.
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">let</span> <span class="Identifier">r</span> <span class="Operator">=</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">"Hello"</span><span class="Punctuation">)</span> <span class="Operator">&</span> <span class="Identifier">rope</span><span class="Punctuation">(</span><span class="StringLit">", Nim!"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">s</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">"Hello"</span><span class="Punctuation">,</span> <span class="StringLit">", Nim!"</span><span class="Punctuation">]</span>
- <span class="Keyword">var</span> <span class="Identifier">index</span> <span class="Operator">=</span> <span class="DecNumber">0</span>
- <span class="Keyword">for</span> <span class="Identifier">leave</span> <span class="Keyword">in</span> <span class="Identifier">r</span><span class="Operator">.</span><span class="Identifier">leaves</span><span class="Punctuation">:</span>
- <span class="Identifier">doAssert</span> <span class="Identifier">leave</span> <span class="Operator">==</span> <span class="Identifier">s</span><span class="Punctuation">[</span><span class="Identifier">index</span><span class="Punctuation">]</span>
- <span class="Identifier">inc</span><span class="Punctuation">(</span><span class="Identifier">index</span><span class="Punctuation">)</span></pre>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/ropes.nim#L257" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/ropes.nim#L257" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- </div>
- </div>
- <div class="twelve-columns footer">
- <span class="nim-sprite"></span>
- <br>
- <small style="color: var(--hint);">Made with Nim. Generated: 2025-01-09 12:00:09 UTC</small>
- </div>
- </div>
- </div>
- <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
-
- </body>
- </html>
|