# Strings

## String Predicates

```(string? val)```
Standard String Predicate. Determine if `val` is a string.

## String Constructors

```(make-string length ch)```
Standard String Procedure. Create a new string of length `length`, containing only copies of `ch`.
```(string ch_0 ch_1 ... ch_n)```
Standard String Procedure. Create a new string of length `n`+1, by concatenating all of `ch_0` through `ch_n`.
```(string-append str_0 str_1 ... str_n)```
Standard String Procedure. Create a new string of by joining together `str` through `str_n` in order. (Much like `append`, but for strings, rather than lists.)

## Extracting Information from Strings

```(string-length str)```
Standard String Procedure. Determine the number of characters in `str`.
```(string-ref str pos)```
Standard String Procedure. Extract the character at a specified position from a string. Like `list-ref`, `string-ref` presupposes zero-based indexing; the position is specified by the number of characters that precede it in the string. Hence, the initial character in the string is at position 0, the next at position 1, and so on.)
```(substring str start end)```
Standard String Procedure. Create a new string by selecting the characters at positions `start` to `end`-1 of `str`. Note that `substring`, like `string-ref` uses 0-based indexing.

## Converting Strings

```(string->list str)```
Standard String Procedure. Convert `str` to a list of characters. The ith element of the list is the ith character in the string.
```(list->string char-list)```
Standard String Procedure. Convert `char-list` (which must be a list of characters) to a string. The ith element of the list becomes the ith character in the string.
```(string->number str)```
Standard String Procedure. Given a string that naturally represents a number (e.g., `"23"` or `"3.14"`, or even `"2.11e-5"`), return the corresponding number.
```(number->string num)```
Standard String Procedure. Convert `num` to an appropriate textual representation.

## Comparing Strings

```(string<? str1 str2)```
Standard String Procedure. Determine whether `str1` lexicographically precedes `str2`. Both `str1` and `str2` must be strings.
```(string<=? str1 str2)```
Standard String Procedure. Holds if `str1` is either the same as `str2` or if `str1` lexicographically precedes `str2`. Both `str1` and `str2` must be strings.
```(string=? str1 str2)```
Standard String Procedure. Holds if `str1` is the same as `str2`. Both `str1` and `str2` must be strings.
```(string>=? str1 str2)```
Standard String Procedure. Holds if `str1` is either the same as `str2` or if `str1` lexicographically follows `str2`. Both `str1` and `str2` must be strings.
```(string>? str1 str2)```
Standard String Procedure. Determine whether `str1` lexicographically follows `str2`. Both `str1` and `str2` must be strings.
```(string-ci<? str1 str2)```
Standard String Procedure. Determine whether `str1` lexicographically precedes `str2`, ignoring case. Both `str1` and `str2` must be strings.
```(string-ci<=? str1 str2)```
Standard String Procedure. Holds if `str1` is either the same as `str2` or if `str1` lexicographically precedes `str2`, ignoring case. Both `str1` and `str2` must be strings.
```(string-ci=? str1 str2)```
Standard String Procedure. Holds if `str1` is the same as `str2`, ignoring case. Both `str1` and `str2` must be strings.
```(string-ci>=? str1 str2)```
Standard String Procedure. Holds if `str1` is either the same as `str2` or if `str1` lexicographically follows `str2`, ignoring case. Both `str1` and `str2` must be strings.
```(string-ci>? str1 str2)```
Standard String Procedure. Determine whether `str1` lexicographically follows `str2`, ignoring case. Both `str1` and `str2` must be strings.

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-10 Janet Davis, Matthew Kluber, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials copyright by John David Stone and Henry Walker and used by permission.)

This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit `http://creativecommons.org/licenses/by-nc/2.5/` or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.