Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[toc:]] == chibi-diff Chibi Scheme's diff library === Module: (chibi diff) ==== {{lcs}} <procedure>(lcs a-ls b-ls #!optional (eq equal?))</procedure> Finds the longest common Subsequence between {{a-ls}} and {{b-ls}}, comparing elements with {{eq}} (default {{equal?}}). Returns this sequence as a list, using the elements from {{a-ls}}. Uses quadratic time and space. ==== {{lcs-with-positions}} <procedure>(lcs-with-positions a-ls b-ls #!optional (eq equal?))</procedure> Variant of {{lcs}} which returns the annotated sequence. The result is a list of the common elements, each represented as a list of 3 values: the element,the zero-indexed position in {{a-ls}} where the element occured, and the position in {{b-ls}}. ==== {{diff}} <procedure>(diff a b #!optional (reader read-line) (eq equal?) (optimal? #f))</procedure> Utility to run lcs on text. {{a}} and {{b}} can be strings or ports, which are tokenized into a sequence by calling {{reader}} until {{eof-object}} is found. Returns a list of three values,the sequences read from {{a}} and {{b}}, and the {{lcs}} result. Unless {{optimal?}} is set, we trim common prefixes/suffixes before computing the lcs. ==== {{write-diff}} <procedure>(write-diff diff #!optional (writer write-line-diffs) (out (current-output-port)))</procedure> Utility to format the result of a {{diff}} to output port {{out}} (default {{(current-output-port)}}). Applies {{writer}} to successive diff chunks. {{writer}} should be a procedure of three arguments: {{(writer subsequence type out)}}. {{subsequence}} is a subsequence from the original input,{{type}} is a symbol indicating the type of diff: {{'same}} if this is part of the lcs, {{'add}} if it is unique to the second input, or {{'remove}} if it is unique to the first input. {{writer}} defaults to {{write-line-diffs}},assuming the default line diffs. ==== {{diff->string}} <procedure>(diff->string diff #!optional (writer write-line-diffs))</procedure> Equivalent to {{write-diff}} but collects the output to a string. ==== {{write-line-diffs}} <procedure>(write-line-diffs lines type out)</procedure> The default writer for {{write-diff}}, annotates simple {{+/-}} prefixes for added/removed lines. ==== {{write-line-diffs/color}} <procedure>(write-line-diffs/color lines type out)</procedure> A variant of {{write-line-diffs}} which adds red/green ANSI coloring to the {{+/-}} prefix. ==== {{write-char-diffs}} <procedure>(write-char-diffs chars type out)</procedure> A diff writer for sequences of characters (when a diff was generated with {{read-char}}), enclosing added characters in {{«...»}} brackets and removed characters in {{»...«}}. ==== {{write-char-diffs/color}} <procedure>(write-char-diffs/color chars type out)</procedure> A diff writer for sequences of characters (when a diff was generated with {{read-char}}), formatting added characters in green and removed characters in red. ==== {{write-edits}} <procedure>(write-edits ls lcs #!optional (index 1) (writer write-line-diffs) (out (current-output-port)))</procedure> Utility to format the result of a {{diff}} with respect to a single input sequence {{ls}}. {{lcs}} is the annotated common sequence from {{diff}} or {{lcs-with-positions}}, and {{index}} is the index (0 or 1, default 1) of {{ls}} in the original call. Since we have no information about the other input, we can only format what is the same and what is different,formatting the differences as either added (if {{index}} is 0) or removed (if {{index}} is 1). ==== {{edits->string}} <procedure>(edits->string ls lcs #!optional (type (quote add)) writer)</procedure> Equivalent to {{write-edits}} but collects the output to a string. ==== {{edits->string/color}} <procedure>(edits->string/color ls lcs #!optional (type (quote add)) writer)</procedure> Equivalent to {{write-edits}} but collects the output to a string and uses a color-aware writer by default. Note with a character diff this returns the original input string as-is, with only ANSI escapes indicating what changed. === Maintainer Diego A. Mundo === Author Alex Shinn === Version History ; 0.1.1 : Fix egg dependencies - add chibi-term ; 0.1.0 : Initial library version === License BSD Copyright (c) 2009-2021 Alex Shinn All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 4 by 9?