String Extensions

Previous Page TOC Index Next Page See Page

Mindy Compiler Mindy Debugger Mindy Object Extensions Streams Library Standard IO Print Library Format Library Melange Interface TK Library Collection extensions Table Extensions String extensions Regular Expressions Transcendental Library Time Library Random Library Matrix Library


The String extensions Library

Designed by the Gwydion Project

1. Introduction

String-extensions is a library of routines for working with characters and strings. String-extensions exports these modules:

String-Conversions
Character-type
String-hacking
Substring-search

2. The String-Conversions Module

The String-Conversions module consists of various useful conversions involving strings. They are:

string-to-integer(string, #key base) => integer [Function]
integer-to-string(integer, #key base) => string [Function]
digit-to-integer(character) => integer [Function]
integer-to-digit(integer) => character [Function]

as(<string>, character) [G.F. Method]


3. The Character-type Module

Character-type is a Dylanized version of the C library ctype.h It contains the following functions:

Function and Argument Type

Returns #t for these characters

    alpha?(character)

a-zA-Z

alphabetic?(character)

a-zA-Z (same as alpha?)

digit?(character)

0-9

alphanumeric?(character)

a-zA-Z0-9

whitespace?(character)

Space, tab, newline, formfeed, carriage return

uppercase?(character)

A-Z

lowercase?(character)

a-z

hex-digit?(character)

0-9a-f

punctuation?(character)

,./<>?;\:"|’[]{}!@#$%^&*()-=_+`~

graphic?(character)

alphanumeric or punctuation

printable?(character)

graphic or whitespace

control?(character)

not printable


4. The String-hacking Module

The String-hacking module exports miscellanous functions and data structures that are useful when working with strings and characters.

add-last(stretchy-sequence, object) => stretchy-sequence [Generic Function]
add-last(string, character) => string [G.F. Method]

predecessor(character) => character [Function]

            as(<character>, -1 + as(<integer>, character))

successor(character) => character [Function]

            as(<character>, 1 + as(<integer>, character))

case-insensitive-equal(object1, object2) [Generic Function]
case-insensitive-equal(string1, string2) [G.F. Method]
case-insensitive-equal(character1, character2) [G.F. Method]

<character-set> [Sealed Abstract Class]
<case-sensitive-character-set> [Class]
<case-insensitive-character-set> [Class]

            make(<case-sensitive-character-set>, description: "a-z")
            as(<case-insensitive-character-set>,

"abcdefghijklmnopqrstuvwxyz")
            as(<case-sensitive-character-set>, "a-z")

<byte-character-table> [Class]

            regular-vector[as(<integer>, character)]
            byte-character-table[character]

5. The Substring-search Module

Substring-search contains methods for searching for fixed substrings. It is as similar to the regular-expression module as we could make it. (See the document The Regular Expressions Library for details about regular expressions, and about the "make-fooer" convention. However, note that while the "make-fooer" convention is obsolete for regular expression functions, it is not obsolete for substring searching.) Substring functions work only on byte strings, and are always case sensitive.

substring-position [Generic Function]

(big-string, search-for-string, #key start, end)
=> position-or-false;

make-substring-positioner [Generic Function]

(search-for-string) => an anonymous positioner
method (big-string, #key start, end) => position-or-false

substring-replace [Generic Function]

(big-string, search-for-string, replace-with-string, #key count, start, end)
=> replaced-string

make-substring-replacer [Generic Function]

(search-for :: <byte-string>, #key replace-with)
=> an anonymous function replacer that is either
method (big-string, #key count, start, end) => new-string
or
method (big-string, replace-with-string, #key count, start, end)

Mindy Compiler Mindy Debugger Mindy Object Extensions Streams Library Standard IO Print Library Format Library Melange Interface TK Library Collection extensions Table Extensions String extensions Regular Expressions Transcendental Library Time Library Random Library Matrix Library

Previous Page TOC Index Next Page See Page

Copyright 1994, 1995, 1996, 1997 Carnegie Mellon University. All rights reserved.

Send comments and bug reports to gwydion-bugs@cs.cmu.edu