Skip to content

Commit

Permalink
Add more documentation for string functions (see JuliaLang#2147 & Jul…
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk committed Feb 12, 2013
1 parent 8f33736 commit bca6844
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion doc/stdlib/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ General Collections

For ordered, indexable collections, the maximum index ``i`` for which ``ref(collection, i)`` is valid. For unordered collections, the number of elements.

.. function:: endof(collection) -> Integer

Returns the last index of the collection.

**Example**: ``endof([1,2,4]) = 3``

Fully implemented by: ``Range``, ``Range1``, ``Tuple``, ``Number``, ``AbstractArray``, ``IntSet``, ``Dict``, ``WeakKeyDict``, ``String``, ``Set``.

Partially implemented by: ``FDSet``.
Expand Down Expand Up @@ -314,6 +320,10 @@ Iterable Collections

**Example**: ``map((x) -> x * 2, [1, 2, 3]) = [2, 4, 6]``

.. function:: map!(function, collection)

In-place version of :func:`map`.

.. function:: mapreduce(f, op, itr)

Applies function ``f`` to each element in ``itr`` and then reduces the result using the binary function ``op``.
Expand Down Expand Up @@ -517,7 +527,7 @@ Dequeues

Remove items at specified range.

.. function:: grow!(collection, n) -> collectionf
.. function:: resize!(collection, n) -> collection

Resize collection to contain ``n`` elements.

Expand Down Expand Up @@ -582,6 +592,26 @@ Strings

Convert a string to a contiguous UTF-8 string (all characters must be valid UTF-8 characters).

.. function:: is_valid_ascii(s) -> Bool

Returns true if the string is valid ASCII, false otherwise.

.. function:: is_valid_utf8(s) -> Bool

Returns true if the string is valid UTF-8, false otherwise.

.. function:: check_ascii(s)

Calls :func:`is_valid_ascii` on string. Throws error if it is not valid.

.. function:: check_utf8(s)

Calls :func:`is_valid_utf8` on string. Throws error if it is not valid.

.. function:: byte_string_classify(s)

Returns 0 if the string is neither valid ASCII nor UTF-8, 1 if it is valid ASCII, and 2 if it is valid UTF-8.

.. function:: search(string, char, [i])

Return the index of ``char`` in ``string``, giving 0 if not found. The second argument may also be a vector or a set of characters. The third argument optionally specifies a starting index.
Expand Down

0 comments on commit bca6844

Please sign in to comment.