Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: egg]] == rope [[toc:]] == Description Ropes, as described in "Ropes, An Alternative to Strings" (1995 - H. Boehm, R. Atkinson, M. Plass). The source for this egg is available [[https://git.foldling.org/rope.git|here]]. == API <record>rope</record> <procedure>(rope? object) => boolean</procedure> <procedure>(rope-length rope) => integer</procedure> <procedure>(rope-depth rope) => integer</procedure> A rope is either a leaf containing a string or a binary tree consisting of such leaves. Length and depth are stored on each node, so {{rope-length}} and {{rope-depth}} are constant time queries. {{rope?}} simply tests if its argument is a rope. <procedure>(rope=? rope1 rope2) => boolean</procedure> {{rope=?}} tests whether two ropes represent the same string. Fast paths are provided on {{eq?}}ity and {{rope-length}}; otherwise, this comparison is O(n). <parameter>(current-maximum-leaf-length [n])</parameter> {{current-maximum-leaf-length}} specifies the maximum string length for rope leaf nodes. The default value is 512, which should be suitable for most purposes. Setting this value too low will result in frequent rebalancing, adversely affecting performance. <procedure>(rope-null? rope) => boolean</procedure> Tests whether the given rope is empty. Equivalent to {{(= 0 (rope-length rope))}}. <procedure>(rope [string ...]) => rope</procedure> Constructs a rope from the given strings. The resulting rope, while not guaranteed to be balanced, should be fairly so. <procedure>(string->rope string [start [end]]) => rope</procedure> Constructs a rope from the given string. The resulting rope is guaranteed to be balanced. If {{start}} and {{end}} indices are given, the resulting rope will consist of only the characters in that range of the string. <procedure>(rope->string rope [start [end]]) => string</procedure> Returns the contents of the given rope as a string. If {{start}} and {{end}} indices are given, the resulting string will consist of only the characters in that range of the rope. <procedure>(rope-ref rope i) => character</procedure> Returns the {{i}}th character of the rope, zero-indexed. <procedure>(rope-set! rope i char) => void</procedure> Sets the {{i}}th character of the rope, zero-indexed, to the given {{char}}. The rope is destructively modified. <procedure>(subrope rope start [end]) => rope</procedure> Returns a subrope consisting of the range of characters starting at the zero-indexed character {{start}} and ending at character {{end}}, or the end of the rope if no {{end}} is given. <procedure>(rope-append [rope ...]) => rope</procedure> Appends the given ropes, trying to keep the resulting rope fairly well-balanced. <procedure>(rope-concatenate list) => rope</procedure> Constructs a new rope from the the given list of ropes, trying to keep the resulting rope fairly well-balanced. <procedure>(rope-reverse rope)</procedure> Constructs a new rope consisting of the characters in the given rope, reversed. This operation is expensive for large ropes (O(n) in the length of the rope, best-case). <procedure>(rope-balanced? rope) => boolean</procedure> Tests whether the given rope is balanced. A rope is balanced if its length is at least {{F(n+2)}}, where {{F(n)}} is the {{n}}th fibonacci number and {{n}} is the depth of the given rope. <procedure>(rope-balance rope) => rope</procedure> Explicitly rebalances a rope. The rebalancing strategy used is that described in Boehm, Atkinson & Plass' 1995 paper "Ropes, An Alternative to Strings". <procedure>(rope-fold f a rope1 [ropen ...]) => object</procedure> <procedure>(rope-for-each f rope1 [ropen ...]) => void</procedure> These procedures implement characterwise {{fold}} and {{for-each}} over the given ropes. <procedure>(read-rope [port [length]]) => rope</procedure> Reads a rope from the given port, or {{current-input-port}} if no port is specified. If a numerical length argument is given, at most that many characters are read. The resulting rope is guaranteed to be balanced. <procedure>(make-rope-iterator rope) => procedure</procedure> Returns a cursor procedure over the given rope's characters. The resulting procedure, when invoked, will return the current character in the rope and advance to the next character. When the characters of the rope are exhausted, the procedure will yield {{#!eof}}. <procedure>(open-input-rope rope) => port</procedure> Returns a port from which the contents of the rope can be read. When the end of the rope is reached, subsequent reads will return {{#!eof}}. <procedure>(open-output-rope) => port</procedure> <procedure>(get-output-rope [port]) => rope</procedure> {{open-output-rope}} returns a port to which output can be written and accumulated, until returned as a rope with {{get-output-rope}}. In reality, {{open-output-rope}} and {{open-output-string}} are the same. Construction of the rope returned by {{get-output-rope}} is delayed until that procedure is called, so {{get-output-rope}} may be used to return a rope from the accumulated output of ports created by either {{open-output-rope}} or {{open-output-string}}. == Author [[/users/evan-hanson|Evan Hanson]] == Repository [[https://git.foldling.org/rope/|https://git.foldling.org/rope/]] == License 3-Clause BSD
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 12 to 9?