Exercises

  1. Write a subroutine that swaps two arrays.

  2. Write a subroutine that verifies that the argument is a correctly formed integer. For extra credit, give it a flag that lets it check for integers; floating-point numbers (with and without exponents); complex, hexadecimal, and octal numbers; or any combination of these.

  3. Write a module to count the words, lines, and characters in a string.

  4. Write a module to print a hash nicely. Handle the case when the values contain new lines. (For extra credit, handle the case when the value contains unprintable characters.)

  5. Write a function to encode a string so that it may be enclosed in double quotes safely. For example:

    This "string" contains a backslash ()
    becomes
    "This "string" contains a backslash (\)"

    Write a function that decodes strings as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset