home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / elisp / elisp-4 < prev    next >
Encoding:
GNU Info File  |  1993-05-31  |  46.5 KB  |  1,252 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.  
  4.    This is edition 2.0 of the GNU Emacs Lisp Reference Manual, for
  5. Emacs Version 19.
  6.  
  7.    Published by the Free Software Foundation, 675 Massachusetts Avenue,
  8. Cambridge, MA 02139 USA
  9.  
  10.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided that
  18. the entire resulting derived work is distributed under the terms of a
  19. permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that this permission notice may be stated in a
  24. translation approved by the Foundation.
  25.  
  26. 
  27. File: elisp,  Node: Predicates on Numbers,  Next: Comparison of Numbers,  Prev: Float Basics,  Up: Numbers
  28.  
  29. Type Predicates for Numbers
  30. ===========================
  31.  
  32.    The functions in this section test whether the argument is a number
  33. or whether it is a certain sort of number.  The functions `integerp'
  34. and `floatp' can take any type of Lisp object as argument (the
  35. predicates would not be of much use otherwise); but the `zerop'
  36. predicate requires a number as its argument.  See also
  37. `integer-or-marker-p' and `number-or-marker-p', in *Note Predicates on
  38. Markers::.
  39.  
  40.  - Function: floatp OBJECT
  41.      This predicate tests whether its argument is a floating point
  42.      number and returns `t' if so, `nil' otherwise.
  43.  
  44.      `floatp' does not exist in Emacs versions 18 and earlier.
  45.  
  46.  - Function: integerp OBJECT
  47.      This predicate tests whether its argument is an integer, and
  48.      returns `t' if so, `nil' otherwise.
  49.  
  50.  - Function: numberp OBJECT
  51.      This predicate tests whether its argument is a number (either
  52.      integer or floating point), and returns `t' if so, `nil' otherwise.
  53.  
  54.  - Function: natnump OBJECT
  55.      The `natnump' predicate (whose name comes from the phrase
  56.      "natural-number-p") tests to see whether its argument is a
  57.      nonnegative integer, and returns `t' if so, `nil' otherwise.  0 is
  58.      considered non-negative.
  59.  
  60.      Markers are not converted to integers, hence `natnump' of a marker
  61.      is always `nil'.
  62.  
  63.      People have pointed out that this function is misnamed, because
  64.      the term "natural number" is usually understood as excluding zero.
  65.      We are open to suggestions for a better name to use in a future
  66.      version.
  67.  
  68.  - Function: zerop NUMBER
  69.      This predicate tests whether its argument is zero, and returns `t'
  70.      if so, `nil' otherwise.  The argument must be a number.
  71.  
  72.      These two forms are equivalent: `(zerop x) == (= x 0)'.
  73.  
  74. 
  75. File: elisp,  Node: Comparison of Numbers,  Next: Numeric Conversions,  Prev: Predicates on Numbers,  Up: Numbers
  76.  
  77. Comparison of Numbers
  78. =====================
  79.  
  80.    Floating point numbers in Emacs Lisp actually take up storage, and
  81. there can be many distinct floating point number objects with the same
  82. numeric value.  If you use `eq' to compare them, then you test whether
  83. two values are the same *object*.  If you want to compare just the
  84. numeric values, use `='.
  85.  
  86.    If you use `eq' to compare two integers, it always returns `t' if
  87. they have the same value.  This is sometimes useful, because `eq'
  88. accepts arguments of any type and never causes an error, whereas `='
  89. signals an error if the arguments are not numbers or markers.  However,
  90. it is a good idea to use `=' if you can, even for comparing integers,
  91. just in case we change the representation of integers in a future Emacs
  92. version.
  93.  
  94.    There is another wrinkle: because floating point arithmetic is not
  95. exact, it is often a bad idea to check for equality of two floating
  96. point values.  Usually it is better to test for approximate equality.
  97. Here's a function to do this:
  98.  
  99.      (defvar fuzz-factor 1.0e-6)
  100.      
  101.      (defun approx-equal (x y)
  102.        (< (/ (abs (- x y))
  103.              (max (abs x) (abs y)))
  104.           fuzz-factor))
  105.  
  106.      Common Lisp note: because of the way numbers are implemented in
  107.      Common Lisp, you generally need to use ``='' to test for equality
  108.      between numbers of any kind.
  109.  
  110.  - Function: = NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  111.      This function tests whether its arguments are the same number, and
  112.      returns `t' if so, `nil' otherwise.
  113.  
  114.  - Function: /= NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  115.      This function tests whether its arguments are not the same number,
  116.      and returns `t' if so, `nil' otherwise.
  117.  
  118.  - Function: < NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  119.      This function tests whether its first argument is strictly less
  120.      than its second argument.  It returns `t' if so, `nil' otherwise.
  121.  
  122.  - Function: <= NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  123.      This function tests whether its first argument is less than or
  124.      equal to its second argument.  It returns `t' if so, `nil'
  125.      otherwise.
  126.  
  127.  - Function: > NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  128.      This function tests whether its first argument is strictly greater
  129.      than its second argument.  It returns `t' if so, `nil' otherwise.
  130.  
  131.  - Function: >= NUMBER-OR-MARKER1 NUMBER-OR-MARKER2
  132.      This function tests whether its first argument is greater than or
  133.      equal to its second argument.  It returns `t' if so, `nil'
  134.      otherwise.
  135.  
  136.  - Function: max NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS
  137.      This function returns the largest of its arguments.
  138.  
  139.           (max 20)
  140.                => 20
  141.           (max 1 2)
  142.                => 2
  143.           (max 1 3 2)
  144.                => 3
  145.  
  146.  - Function: min NUMBER-OR-MARKER &rest NUMBERS-OR-MARKERS
  147.      This function returns the smallest of its arguments.
  148.  
  149. 
  150. File: elisp,  Node: Numeric Conversions,  Next: Arithmetic Operations,  Prev: Comparison of Numbers,  Up: Numbers
  151.  
  152. Numeric Conversions
  153. ===================
  154.  
  155.    To convert an integer to floating point, use the function `float'.
  156.  
  157.  - Function: float NUMBER
  158.      This returns NUMBER converted to floating point.  If NUMBER is
  159.      already a floating point number, `float' returns it unchanged.
  160.  
  161.    There are four functions to convert floating point numbers to
  162. integers; they differ in how they round.  You can call these functions
  163. with an integer argument also; if you do, they return it without change.
  164.  
  165.  - Function: truncate NUMBER
  166.      This returns NUMBER, converted to an integer by rounding towards
  167.      zero.
  168.  
  169.  - Function: floor NUMBER
  170.      This returns NUMBER, converted to an integer by rounding downward
  171.      (towards negative infinity).
  172.  
  173.  - Function: ceiling NUMBER
  174.      This returns NUMBER, converted to an integer by rounding upward
  175.      (towards positive infinity).
  176.  
  177.  - Function: round NUMBER
  178.      This returns NUMBER, converted to an integer by rounding towards
  179.      the nearest integer.
  180.  
  181. 
  182. File: elisp,  Node: Arithmetic Operations,  Next: Bitwise Operations,  Prev: Numeric Conversions,  Up: Numbers
  183.  
  184. Arithmetic Operations
  185. =====================
  186.  
  187.    Emacs Lisp provides the traditional four arithmetic operations:
  188. addition, subtraction, multiplication, and division.  A remainder
  189. function supplements the (integer) division function.  The functions to
  190. add or subtract 1 are provided because they are traditional in Lisp and
  191. commonly used.
  192.  
  193.    All of these functions except `%' return a floating point value if
  194. any argument is floating.
  195.  
  196.    It is important to note that in GNU Emacs Lisp, arithmetic functions
  197. do not check for overflow.  Thus `(1+ 8388607)' may equal -8388608,
  198. depending on your hardware.
  199.  
  200.  - Function: 1+ NUMBER-OR-MARKER
  201.      This function returns NUMBER-OR-MARKER plus 1.  For example,
  202.  
  203.           (setq foo 4)
  204.                => 4
  205.           (1+ foo)
  206.                => 5
  207.  
  208.      This function is not analogous to the C operator `++'--it does not
  209.      increment a variable.  It just computes a sum.  Thus,
  210.  
  211.           foo
  212.                => 4
  213.  
  214.      If you want to increment the variable, you must use `setq', like
  215.      this:
  216.  
  217.           (setq foo (1+ foo))
  218.                => 5
  219.  
  220.  - Function: 1- NUMBER-OR-MARKER
  221.      This function returns NUMBER-OR-MARKER minus 1.
  222.  
  223.  - Function: abs NUMBER
  224.      This returns the absolute value of NUMBER.
  225.  
  226.  - Function: + &rest NUMBERS-OR-MARKERS
  227.      This function adds its arguments together.  When given no
  228.      arguments, `+' returns 0.  It does not check for overflow.
  229.  
  230.           (+)
  231.                => 0
  232.           (+ 1)
  233.                => 1
  234.           (+ 1 2 3 4)
  235.                => 10
  236.  
  237.  - Function: - &optional NUMBER-OR-MARKER &rest OTHER-NUMBERS-OR-MARKERS
  238.      The `-' function serves two purposes: negation and subtraction.
  239.      When `-' has a single argument, the value is the negative of the
  240.      argument.  When there are multiple arguments, each of the
  241.      OTHER-NUMBERS-OR-MARKERS is subtracted from NUMBER-OR-MARKER,
  242.      cumulatively.  If there are no arguments, the result is 0.  This
  243.      function does not check for overflow.
  244.  
  245.           (- 10 1 2 3 4)
  246.                => 0
  247.           (- 10)
  248.                => -10
  249.           (-)
  250.                => 0
  251.  
  252.  - Function: * &rest NUMBERS-OR-MARKERS
  253.      This function multiplies its arguments together, and returns the
  254.      product.  When given no arguments, `*' returns 1.  It does not
  255.      check for overflow.
  256.  
  257.           (*)
  258.                => 1
  259.           (* 1)
  260.                => 1
  261.           (* 1 2 3 4)
  262.                => 24
  263.  
  264.  - Function: / DIVIDEND DIVISOR &rest DIVISORS
  265.      This function divides DIVIDEND by DIVISORS and returns the
  266.      quotient.  If there are additional arguments DIVISORS, then
  267.      DIVIDEND is divided by each divisor in turn.  Each argument may be
  268.      a number or a marker.
  269.  
  270.      If all the arguments are integers, then the result is an integer
  271.      too.  This means the result has to be rounded.  On most machines,
  272.      the result is rounded towards zero after each division, but some
  273.      machines may round differently with negative arguments.  This is
  274.      because the Lisp function `/' is implemented using the C division
  275.      operator, which has the same possibility for machine-dependent
  276.      rounding.  As a practical matter, all known machines round in the
  277.      standard fashion.
  278.  
  279.      If you divide by 0, an `arith-error' error is signaled.  (*Note
  280.      Errors::.)
  281.  
  282.           (/ 6 2)
  283.                => 3
  284.           (/ 5 2)
  285.                => 2
  286.           (/ 25 3 2)
  287.                => 4
  288.           (/ -17 6)
  289.                => -2
  290.  
  291.      Since the division operator in Emacs Lisp is implemented using the
  292.      division operator in C, the result of dividing negative numbers
  293.      may in principle vary from machine to machine, depending on how
  294.      they round the result.  Thus, the result of `(/ -17 6)' could be
  295.      -3 on some machines.  In practice, nearly all machines round the
  296.      quotient towards 0.
  297.  
  298.  - Function: % DIVIDEND DIVISOR
  299.      This function returns the value of DIVIDEND modulo DIVISOR; in
  300.      other words, the integer remainder after division of DIVIDEND by
  301.      DIVISOR.  The sign of the result is the sign of DIVIDEND.  The
  302.      sign of DIVISOR is ignored.  The arguments must be integers.
  303.  
  304.      For negative arguments, the value is in principle machine-dependent
  305.      since the quotient is; but in practice, all known machines behave
  306.      alike.
  307.  
  308.      An `arith-error' results if DIVISOR is 0.
  309.  
  310.           (% 9 4)
  311.                => 1
  312.           (% -9 4)
  313.                => -1
  314.           (% 9 -4)
  315.                => 1
  316.           (% -9 -4)
  317.                => -1
  318.  
  319.      For any two numbers DIVIDEND and DIVISOR,
  320.  
  321.           (+ (% DIVIDEND DIVISOR)
  322.              (* (/ DIVIDEND DIVISOR) DIVISOR))
  323.  
  324.      always equals DIVIDEND.
  325.  
  326. 
  327. File: elisp,  Node: Bitwise Operations,  Next: Transcendental Functions,  Prev: Arithmetic Operations,  Up: Numbers
  328.  
  329. Bitwise Operations on Integers
  330. ==============================
  331.  
  332.    In a computer, an integer is represented as a binary number, a
  333. sequence of "bits" (digits which are either zero or one).  A bitwise
  334. operation acts on the individual bits of such a sequence.  For example,
  335. "shifting" moves the whole sequence left or right one or more places,
  336. reproducing the same pattern "moved over".
  337.  
  338.    The bitwise operations in Emacs Lisp apply only to integers.
  339.  
  340.  - Function: lsh INTEGER1 COUNT
  341.      `lsh', which is an abbreviation for "logical shift", shifts the
  342.      bits in INTEGER1 to the left COUNT places, or to the right if
  343.      COUNT is negative.  If COUNT is negative, `lsh' shifts zeros into
  344.      the most-significant bit, producing a positive result even if
  345.      INTEGER1 is negative.  Contrast this with `ash', below.
  346.  
  347.      Thus, the decimal number 5 is the binary number 00000101.  Shifted
  348.      once to the left, with a zero put in the one's place, the number
  349.      becomes 00001010, decimal 10.
  350.  
  351.      Here are two examples of shifting the pattern of bits one place to
  352.      the left.  Since the contents of the rightmost place has been
  353.      moved one place to the left, a value has to be inserted into the
  354.      rightmost place.  With `lsh', a zero is placed into the rightmost
  355.      place.  (These examples show only the low-order eight bits of the
  356.      binary pattern; the rest are all zero.)
  357.  
  358.           (lsh 5 1)
  359.                => 10
  360.           
  361.           ;; Decimal 5 becomes decimal 10.
  362.           00000101 => 00001010
  363.           
  364.           (lsh 7 1)
  365.                => 14
  366.           
  367.           ;; Decimal 7 becomes decimal 14.
  368.           00000111 => 00001110
  369.  
  370.      As the examples illustrate, shifting the pattern of bits one place
  371.      to the left produces a number that is twice the value of the
  372.      previous number.
  373.  
  374.      Note, however that functions do not check for overflow, and a
  375.      returned value may be negative (and in any case, no more than a 24
  376.      bit value) when an integer is sufficiently left shifted.
  377.  
  378.      For example, left shifting 8,388,607 produces -2:
  379.  
  380.           (lsh 8388607 1)          ; left shift
  381.                => -2
  382.  
  383.      In binary, in the 24 bit implementation, the numbers looks like
  384.      this:
  385.  
  386.           ;; Decimal 8,388,607
  387.           0111 1111  1111 1111  1111 1111
  388.  
  389.      which becomes the following when left shifted:
  390.  
  391.           ;; Decimal -2
  392.           1111 1111  1111 1111  1111 1110
  393.  
  394.      Shifting the pattern of bits two places to the left produces
  395.      results like this (with 8-bit binary numbers):
  396.  
  397.           (lsh 3 2)
  398.                => 12
  399.           
  400.           ;; Decimal 3 becomes decimal 12.
  401.           00000011 => 00001100
  402.  
  403.      On the other hand, shifting the pattern of bits one place to the
  404.      right looks like this:
  405.  
  406.           (lsh 6 -1)
  407.                => 3
  408.           
  409.           ;; Decimal 6 becomes decimal 3.
  410.           00000110 => 00000011
  411.           
  412.           (lsh 5 -1)
  413.                => 2
  414.           
  415.           ;; Decimal 5 becomes decimal 2.
  416.           00000101 => 00000010
  417.  
  418.      As the example illustrates, shifting the pattern of bits one place
  419.      to the right divides the value of the binary number by two,
  420.      rounding downward.
  421.  
  422.  - Function: ash INTEGER1 COUNT
  423.      `ash' ("arithmetic shift") shifts the bits in INTEGER1 to the left
  424.      COUNT places, or to the right if COUNT is negative.
  425.  
  426.      `ash' gives the same results as `lsh' except when INTEGER1 and
  427.      COUNT are both negative.  In that case, `ash' puts a one in the
  428.      leftmost position, while `lsh' puts a zero in the leftmost
  429.      position.
  430.  
  431.      Thus, with `ash', shifting the pattern of bits one place to the
  432.      right looks like this:
  433.  
  434.           (ash -6 -1)
  435.                => -3
  436.           
  437.           ;; Decimal -6
  438.           ;; becomes decimal -3.
  439.           
  440.           1111 1111  1111 1111  1111 1010
  441.                =>
  442.           1111 1111  1111 1111  1111 1101
  443.  
  444.      In contrast, shifting the pattern of bits one place to the right
  445.      with `lsh' looks like this:
  446.  
  447.           (lsh -6 -1)
  448.                => 8388605
  449.           
  450.           ;; Decimal -6
  451.           ;; becomes decimal 8,388,605.
  452.           
  453.           1111 1111  1111 1111  1111 1010
  454.                =>
  455.           0111 1111  1111 1111  1111 1101
  456.  
  457.      In this case, the 1 in the leftmost position is shifted one place
  458.      to the right, and a zero is shifted into the leftmost position.
  459.  
  460.      Here are other examples:
  461.  
  462.           ;               24-bit binary values
  463.           
  464.           (lsh 5 2)          ;   5  =  0000 0000  0000 0000  0000 0101
  465.                => 20         ;  20  =  0000 0000  0000 0000  0001 0100
  466.  
  467.           (ash 5 2)
  468.                => 20
  469.           (lsh -5 2)         ;  -5  =  1111 1111  1111 1111  1111 1011
  470.                => -20        ; -20  =  1111 1111  1111 1111  1110 1100
  471.           (ash -5 2)
  472.                => -20
  473.  
  474.           (lsh 5 -2)         ;   5  =  0000 0000  0000 0000  0000 0101
  475.                => 1          ;   1  =  0000 0000  0000 0000  0000 0001
  476.  
  477.           (ash 5 -2)
  478.                => 1
  479.  
  480.           (lsh -5 -2)        ;  -5  =  1111 1111  1111 1111  1111 1011
  481.                => 4194302    ;         0011 1111  1111 1111  1111 1110
  482.  
  483.           (ash -5 -2)        ;  -5  =  1111 1111  1111 1111  1111 1011
  484.                => -2         ;  -2  =  1111 1111  1111 1111  1111 1110
  485.  
  486.  - Function: logand &rest INTS-OR-MARKERS
  487.      This function returns the "logical and" of the arguments: the Nth
  488.      bit is set in the result if, and only if, the Nth bit is set in
  489.      all the arguments.  ("Set" means that the value of the bit is 1
  490.      rather than 0.)
  491.  
  492.      For example, using 4-bit binary numbers, the "logical and" of 13
  493.      and 12 is 12: 1101 combined with 1100 produces 1100.
  494.  
  495.      In both the binary numbers, the leftmost two bits are set (i.e.,
  496.      they are 1's), so the leftmost two bits of the returned value are
  497.      set.  However, for the rightmost two bits, each is zero in at
  498.      least one of the arguments, so the rightmost two bits of the
  499.      returned value are 0's.
  500.  
  501.      Therefore,
  502.  
  503.           (logand 13 12)
  504.                => 12
  505.  
  506.      If `logand' is not passed any argument, it returns a value of -1.
  507.      This number is an identity element for `logand' because its binary
  508.      representation consists entirely of ones.  If `logand' is passed
  509.      just one argument, it returns that argument.
  510.  
  511.           ;                24-bit binary values
  512.           
  513.           (logand 14 13)     ; 14  =  0000 0000  0000 0000  0000 1110
  514.                              ; 13  =  0000 0000  0000 0000  0000 1101
  515.                => 12         ; 12  =  0000 0000  0000 0000  0000 1100
  516.  
  517.           (logand 14 13 4)   ; 14  =  0000 0000  0000 0000  0000 1110
  518.                              ; 13  =  0000 0000  0000 0000  0000 1101
  519.                              ;  4  =  0000 0000  0000 0000  0000 0100
  520.                => 4          ;  4  =  0000 0000  0000 0000  0000 0100
  521.  
  522.           (logand)
  523.                => -1         ; -1  =  1111 1111  1111 1111  1111 1111
  524.  
  525.  - Function: logior &rest INTS-OR-MARKERS
  526.      This function returns the "inclusive or" of its arguments: the Nth
  527.      bit is set in the result if, and only if, the Nth bit is set in at
  528.      least one of the arguments.  If there are no arguments, the result
  529.      is zero, which is an identity element for this operation.  If
  530.      `logior' is passed just one argument, it returns that argument.
  531.  
  532.           ;               24-bit binary values
  533.           
  534.           (logior 12 5)      ; 12  =  0000 0000  0000 0000  0000 1100
  535.                              ;  5  =  0000 0000  0000 0000  0000 0101
  536.                => 13         ; 13  =  0000 0000  0000 0000  0000 1101
  537.  
  538.           (logior 12 5 7)    ; 12  =  0000 0000  0000 0000  0000 1100
  539.                              ;  5  =  0000 0000  0000 0000  0000 0101
  540.                              ;  7  =  0000 0000  0000 0000  0000 0111
  541.                => 15         ; 15  =  0000 0000  0000 0000  0000 1111
  542.  
  543.  - Function: logxor &rest INTS-OR-MARKERS
  544.      This function returns the "exclusive or" of its arguments: the Nth
  545.      bit is set in the result if, and only if, the Nth bit is set in an
  546.      odd number of the arguments.  If there are no arguments, the
  547.      result is 0.  If `logxor' is passed just one argument, it returns
  548.      that argument.
  549.  
  550.           ;               24-bit binary values
  551.           
  552.           (logxor 12 5)      ; 12  =  0000 0000  0000 0000  0000 1100
  553.                              ;  5  =  0000 0000  0000 0000  0000 0101
  554.                => 9          ;  9  =  0000 0000  0000 0000  0000 1001
  555.  
  556.           (logxor 12 5 7)    ; 12  =  0000 0000  0000 0000  0000 1100
  557.                              ;  5  =  0000 0000  0000 0000  0000 0101
  558.                              ;  7  =  0000 0000  0000 0000  0000 0111
  559.                => 14         ; 14  =  0000 0000  0000 0000  0000 1110
  560.  
  561.  - Function: lognot INTEGER
  562.      This function returns the logical complement of its argument: the
  563.      Nth bit is one in the result if, and only if, the Nth bit is zero
  564.      in INTEGER, and vice-versa.
  565.  
  566.           ;;  5  =  0000 0000  0000 0000  0000 0101
  567.           ;; becomes
  568.           ;; -6  =  1111 1111  1111 1111  1111 1010
  569.           
  570.           (lognot 5)
  571.                => -6
  572.  
  573. 
  574. File: elisp,  Node: Transcendental Functions,  Next: Random Numbers,  Prev: Bitwise Operations,  Up: Numbers
  575.  
  576. Transcendental Functions
  577. ========================
  578.  
  579.    These mathematical functions are available if floating point is
  580. supported.  They allow integers as well as floating point numbers as
  581. arguments.
  582.  
  583.  - Function: sin ARG
  584.  - Function: cos ARG
  585.  - Function: tan ARG
  586.      These are the ordinary trigonometric functions, with argument
  587.      measured in radians.
  588.  
  589.  - Function: asin ARG
  590.      The value of `(asin ARG)' is a number between - pi / 2 and pi / 2
  591.      (inclusive) whose sine is ARG; if, however, ARG is out of range
  592.      (outside [-1, 1]), then the result is a NaN.
  593.  
  594.  - Function: acos ARG
  595.      The value of `(acos ARG)' is a number between 0 and pi (inclusive)
  596.      whose cosine is ARG; if, however, ARG is out of range (outside
  597.      [-1, 1]), then the result is a NaN.
  598.  
  599.  - Function: atan ARG
  600.      The value of `(atan ARG)' is a number between - pi / 2 and pi / 2
  601.      (exclusive) whose tangent is ARG.
  602.  
  603.  - Function: exp ARG
  604.      This is the exponential function; it returns e to the power ARG.
  605.  
  606.  - Function: log ARG &optional BASE
  607.      This function returns the logarithm of ARG, with base BASE.  If
  608.      you don't specify BASE, the base E is used.  If ARG is negative,
  609.      the result is a NaN.
  610.  
  611.  - Function: log10 ARG
  612.      This function returns the logarithm of ARG, with base 10.  If ARG
  613.      is negative, the result is a NaN.
  614.  
  615.  - Function: expt X Y
  616.      This function returns X raised to power Y.
  617.  
  618.  - Function: sqrt ARG
  619.      This returns the square root of ARG.
  620.  
  621. 
  622. File: elisp,  Node: Random Numbers,  Prev: Transcendental Functions,  Up: Numbers
  623.  
  624. Random Numbers
  625. ==============
  626.  
  627.    In a computer, a series of pseudo-random numbers is generated in a
  628. deterministic fashion.  The numbers are not truly random, but they have
  629. certain properties that mimic a random series.  For example, all
  630. possible values occur equally often in a pseudo-random series.
  631.  
  632.    In Emacs, pseudo-random numbers are generated from a "seed" number.
  633. Starting from any given seed, the `random' function always generates
  634. the same sequence of numbers.  Emacs always starts with the same seed
  635. value, so the sequence of values of `random' is actually the same in
  636. each Emacs run!  For example, in one operating system, the first call
  637. to `(random)' after you start Emacs always returns -1457731, and the
  638. second one always returns -7692030.  This is helpful for debugging.
  639.  
  640.    If you want truly unpredictable random numbers, execute `(random
  641. t)'.  This chooses a new seed based on the current time of day and on
  642. Emacs' process ID number.
  643.  
  644.  - Function: random &optional LIMIT
  645.      This function returns a pseudo-random integer.  When called more
  646.      than once, it returns a series of pseudo-random integers.
  647.  
  648.      If LIMIT is `nil', then the value may in principle be any integer.
  649.      If LIMIT is a positive integer, the value is chosen to be
  650.      nonnegative and less than LIMIT (only in Emacs 19).
  651.  
  652.      If LIMIT is `t', it means to choose a new seed based on the
  653.      current time of day and on Emacs's process ID number.
  654.  
  655.      On some machines, any integer representable in Lisp may be the
  656.      result of `random'.  On other machines, the result can never be
  657.      larger than a certain maximum or less than a certain (negative)
  658.      minimum.
  659.  
  660. 
  661. File: elisp,  Node: Strings and Characters,  Next: Lists,  Prev: Numbers,  Up: Top
  662.  
  663. Strings and Characters
  664. **********************
  665.  
  666.    A string in Emacs Lisp is an array that contains an ordered sequence
  667. of characters.  Strings are used as names of symbols, buffers, and
  668. files, to send messages to users, to hold text being copied between
  669. buffers, and for many other purposes.  Because strings are so
  670. important, many functions are provided expressly for manipulating them.
  671. Emacs Lisp programs use strings more often than individual characters.
  672.  
  673. * Menu:
  674.  
  675. * Intro to Strings::          Basic properties of strings and characters.
  676. * Predicates for Strings::    Testing whether an object is a string or char.
  677. * Creating Strings::          Functions to allocate new strings.
  678. * Text Comparison::           Comparing characters or strings.
  679. * String Conversion::         Converting characters or strings and vice versa.
  680. * Formatting Strings::        `format': Emacs's analog of `printf'.
  681. * Character Case::            Case conversion functions.
  682. * Case Table::              Customizing case conversion.
  683.  
  684.    *Note Strings of Events::, for special considerations when using
  685. strings of keyboard character events.
  686.  
  687. 
  688. File: elisp,  Node: Intro to Strings,  Next: Predicates for Strings,  Up: Strings and Characters
  689.  
  690. Introduction to Strings and Characters
  691. ======================================
  692.  
  693.    Strings in Emacs Lisp are arrays that contain an ordered sequence of
  694. characters.  Characters are represented in Emacs Lisp as integers;
  695. whether an integer was intended as a character or not is determined only
  696. by how it is used.  Thus, strings really contain integers.
  697.  
  698.    The length of a string (like any array) is fixed and independent of
  699. the string contents, and cannot be altered.  Strings in Lisp are *not*
  700. terminated by a distinguished character code.  (By contrast, strings in
  701. C are terminated by a character with ASCII code 0.) This means that any
  702. character, including the null character (ASCII code 0), is a valid
  703. element of a string.
  704.  
  705.    Since strings are considered arrays, you can operate on them with the
  706. general array functions.  (*Note Sequences Arrays Vectors::.)  For
  707. example, you can access or change individual characters in a string
  708. using the functions `aref' and `aset' (*note Array Functions::.).
  709.  
  710.    Each character in a string is stored in a single byte.  Therefore,
  711. numbers not in the range 0 to 255 are truncated when stored into a
  712. string.  This means that a string takes up much less memory than a
  713. vector of the same length.
  714.  
  715.    Sometimes key sequences are represented as strings.  When a string is
  716. a key sequence, string elements in the range 128 to 255 represent meta
  717. characters (which are extremely large integers) rather than keyboard
  718. events in the range 128 to 255.
  719.  
  720.    Strings cannot hold characters that have the hyper, super or alt
  721. modifiers; they can hold ASCII control characters, but no others.  They
  722. do not distinguish case in ASCII control characters.  *Note Character
  723. Type::, for more information about representation of meta and other
  724. modifiers for keyboard input characters.
  725.  
  726.    Like a buffer, a string can contain text properties for the
  727. characters in it, as well as the characters themselves.  *Note Text
  728. Properties::.
  729.  
  730.    *Note Text::, for information about functions that display strings or
  731. copy them into buffers.  *Note Character Type::, and *Note String
  732. Type::, for information about the syntax of characters and strings.
  733.  
  734. 
  735. File: elisp,  Node: Predicates for Strings,  Next: Creating Strings,  Prev: Intro to Strings,  Up: Strings and Characters
  736.  
  737. The Predicates for Strings
  738. ==========================
  739.  
  740.    For more information about general sequence and array predicates,
  741. see *Note Sequences Arrays Vectors::, and *Note Arrays::.
  742.  
  743.  - Function: stringp OBJECT
  744.      This function returns `t' if OBJECT is a string, `nil' otherwise.
  745.  
  746.  - Function: char-or-string-p OBJECT
  747.      This function returns `t' if OBJECT is a string or a character
  748.      (i.e., an integer), `nil' otherwise.
  749.  
  750. 
  751. File: elisp,  Node: Creating Strings,  Next: Text Comparison,  Prev: Predicates for Strings,  Up: Strings and Characters
  752.  
  753. Creating Strings
  754. ================
  755.  
  756.    The following functions create strings, either from scratch, or by
  757. putting strings together, or by taking them apart.
  758.  
  759.  - Function: make-string COUNT CHARACTER
  760.      This function returns a string made up of COUNT repetitions of
  761.      CHARACTER.  If COUNT is negative, an error is signaled.
  762.  
  763.           (make-string 5 ?x)
  764.                => "xxxxx"
  765.           (make-string 0 ?x)
  766.                => ""
  767.  
  768.      Other functions to compare with this one include `char-to-string'
  769.      (*note String Conversion::.), `make-vector' (*note Vectors::.), and
  770.      `make-list' (*note Building Lists::.).
  771.  
  772.  - Function: substring STRING START &optional END
  773.      This function returns a new string which consists of those
  774.      characters from STRING in the range from (and including) the
  775.      character at the index START up to (but excluding) the character
  776.      at the index END.  The first character is at index zero.
  777.  
  778.           (substring "abcdefg" 0 3)
  779.                => "abc"
  780.  
  781.      Here the index for `a' is 0, the index for `b' is 1, and the index
  782.      for `c' is 2.  Thus, three letters, `abc', are copied from the
  783.      full string.  The index 3 marks the character position up to which
  784.      the substring is copied.  The character whose index is 3 is
  785.      actually the fourth character in the string.
  786.  
  787.      A negative number counts from the end of the string, so that -1
  788.      signifies the index of the last character of the string.  For
  789.      example:
  790.  
  791.           (substring "abcdefg" -3 -1)
  792.                => "ef"
  793.  
  794.      In this example, the index for `e' is -3, the index for `f' is -2,
  795.      and the index for `g' is -1.  Therefore, `e' and `f' are included,
  796.      and `g' is excluded.
  797.  
  798.      When `nil' is used as an index, it falls after the last character
  799.      in the string.  Thus:
  800.  
  801.           (substring "abcdefg" -3 nil)
  802.                => "efg"
  803.  
  804.      Omitting the argument END is equivalent to specifying `nil'.  It
  805.      follows that `(substring STRING 0)' returns a copy of all of
  806.      STRING.
  807.  
  808.           (substring "abcdefg" 0)
  809.                => "abcdefg"
  810.  
  811.      But we recommend `copy-sequence' for this purpose (*note Sequence
  812.      Functions::.).
  813.  
  814.      A `wrong-type-argument' error is signaled if either START or END
  815.      are non-integers.  An `args-out-of-range' error is signaled if
  816.      START indicates a character following END, or if either integer is
  817.      out of range for STRING.
  818.  
  819.      Contrast this function with `buffer-substring' (*note Buffer
  820.      Contents::.), which returns a string containing a portion of the
  821.      text in the current buffer.  The beginning of a string is at index
  822.      0, but the beginning of a buffer is at index 1.
  823.  
  824.  - Function: concat &rest SEQUENCES
  825.      This function returns a new string consisting of the characters in
  826.      the arguments passed to it.  The arguments may be strings, lists
  827.      of numbers, or vectors of numbers; they are not themselves
  828.      changed.  If no arguments are passed to `concat', it returns an
  829.      empty string.
  830.  
  831.           (concat "abc" "-def")
  832.                => "abc-def"
  833.           (concat "abc" (list 120 (+ 256 121)) [122])
  834.                => "abcxyz"
  835.           (concat "The " "quick brown " "fox.")
  836.                => "The quick brown fox."
  837.           (concat)
  838.                => ""
  839.  
  840.      The second example above shows how characters stored in strings are
  841.      taken modulo 256.  In other words, each character in the string is
  842.      stored in one byte.
  843.  
  844.      The `concat' function always constructs a new string that is not
  845.      `eq' to any existing string.
  846.  
  847.      When an argument is an integer (not a sequence of integers), it is
  848.      converted to a string of digits making up the decimal printed
  849.      representation of the integer.  This special case exists for
  850.      compatibility with Mocklisp, and we don't recommend you take
  851.      advantage of it.  If you want to convert an integer in this way,
  852.      use `format' (*note Formatting Strings::.) or `int-to-string'
  853.      (*note String Conversion::.).
  854.  
  855.           (concat 137)
  856.                => "137"
  857.           (concat 54 321)
  858.                => "54321"
  859.  
  860.      For information about other concatenation functions, see the
  861.      description of `mapconcat' in *Note Mapping Functions::, `vconcat'
  862.      in *Note Vectors::, and `append' in *Note Building Lists::.
  863.  
  864. 
  865. File: elisp,  Node: Text Comparison,  Next: String Conversion,  Prev: Creating Strings,  Up: Strings and Characters
  866.  
  867. Comparison of Characters and Strings
  868. ====================================
  869.  
  870.  - Function: char-equal CHARACTER1 CHARACTER2
  871.      This function returns `t' if the arguments represent the same
  872.      character, `nil' otherwise.  This function ignores differences in
  873.      case if `case-fold-search' is non-`nil'.
  874.  
  875.           (char-equal ?x ?x)
  876.                => t
  877.           (char-to-string (+ 256 ?x))
  878.                => "x"
  879.           (char-equal ?x  (+ 256 ?x))
  880.                => t
  881.  
  882.  - Function: string= STRING1 STRING2
  883.      This function returns `t' if the characters of the two strings
  884.      match exactly; case is significant.
  885.  
  886.           (string= "abc" "abc")
  887.                => t
  888.           (string= "abc" "ABC")
  889.                => nil
  890.           (string= "ab" "ABC")
  891.                => nil
  892.  
  893.  - Function: string-equal STRING1 STRING2
  894.      `string-equal' is another name for `string='.
  895.  
  896.  - Function: string< STRING1 STRING2
  897.      This function compares two strings a character at a time.  First it
  898.      scans both the strings at once to find the first pair of
  899.      corresponding characters that do not match.  If the lesser
  900.      character of those two is the character from STRING1, then STRING1
  901.      is less, and this function returns `t'.  If the lesser character
  902.      is the one from STRING2, then STRING1 is greater, and this
  903.      function returns `nil'.  If the two strings match entirely, the
  904.      value is `nil'.
  905.  
  906.      Pairs of characters are compared by their ASCII codes.  Keep in
  907.      mind that lower case letters have higher numeric values in the
  908.      ASCII character set than their upper case counterparts; numbers and
  909.      many punctuation characters have a lower numeric value than upper
  910.      case letters.
  911.  
  912.           (string< "abc" "abd")
  913.                => t
  914.           (string< "abd" "abc")
  915.                => nil
  916.           (string< "123" "abc")
  917.                => t
  918.  
  919.      When the strings have different lengths, and they match up to the
  920.      length of STRING1, then the result is `t'.  If they match up to
  921.      the length of STRING2, the result is `nil'.  A string without any
  922.      characters in it is the smallest possible string.
  923.  
  924.           (string< "" "abc")
  925.                => t
  926.           (string< "ab" "abc")
  927.                => t
  928.           (string< "abc" "")
  929.                => nil
  930.           (string< "abc" "ab")
  931.                => nil
  932.           (string< "" "")
  933.                => nil
  934.  
  935.  - Function: string-lessp STRING1 STRING2
  936.      `string-lessp' is another name for `string<'.
  937.  
  938.    See `compare-buffer-substrings' in *Note Comparing Text::, for a way
  939. to compare text in buffers.
  940.  
  941. 
  942. File: elisp,  Node: String Conversion,  Next: Formatting Strings,  Prev: Text Comparison,  Up: Strings and Characters
  943.  
  944. Conversion of Characters and Strings
  945. ====================================
  946.  
  947.    Characters and strings may be converted into each other and into
  948. integers.  `format' and `prin1-to-string' (*note Output Functions::.)
  949. may also be used to convert Lisp objects into strings.
  950. `read-from-string' (*note Input Functions::.) may be used to "convert"
  951. a string representation of a Lisp object into an object.
  952.  
  953.    *Note Documentation::, for a description of functions which return a
  954. string representing the Emacs standard notation of the argument
  955. character (`single-key-description' and `text-char-description').
  956. These functions are used primarily for printing help messages.
  957.  
  958.  - Function: char-to-string CHARACTER
  959.      This function returns a new string with a length of one character.
  960.      The value of CHARACTER, modulo 256, is used to initialize the
  961.      element of the string.
  962.  
  963.      This function is similar to `make-string' with an integer argument
  964.      of 1.  (*Note Creating Strings::.)  This conversion can also be
  965.      done with `format' using the `%c' format specification.  (*Note
  966.      Formatting Strings::.)
  967.  
  968.           (char-to-string ?x)
  969.                => "x"
  970.           (char-to-string (+ 256 ?x))
  971.                => "x"
  972.           (make-string 1 ?x)
  973.                => "x"
  974.  
  975.  - Function: string-to-char STRING
  976.      This function returns the first character in STRING.  If the
  977.      string is empty, the function returns 0.  The value is also 0 when
  978.      the first character of STRING is the null character, ASCII code 0.
  979.  
  980.           (string-to-char "ABC")
  981.                => 65
  982.           (string-to-char "xyz")
  983.                => 120
  984.           (string-to-char "")
  985.                => 0
  986.           (string-to-char "\000")
  987.                => 0
  988.  
  989.      This function may be eliminated in the future if it does not seem
  990.      useful enough to retain.
  991.  
  992.  - Function: number-to-string NUMBER
  993.  - Function: int-to-string NUMBER
  994.      This function returns a string consisting of the printed
  995.      representation of NUMBER, which may be an integer or a floating
  996.      point number.  The value starts with a sign if the argument is
  997.      negative.
  998.  
  999.           (int-to-string 256)
  1000.                => "256"
  1001.           (int-to-string -23)
  1002.                => "-23"
  1003.           (int-to-string -23.5)
  1004.                => "-23.5"
  1005.  
  1006.      See also the function `format' in *Note Formatting Strings::.
  1007.  
  1008.  - Function: string-to-number STRING
  1009.  - Function: string-to-int STRING
  1010.      This function returns the integer value of the characters in
  1011.      STRING, read as a number in base ten.  It skips spaces at the
  1012.      beginning of STRING, then reads as much of STRING as it can
  1013.      interpret as a number.  (On some systems it ignores other
  1014.      whitespace at the beginning, not just spaces.)  If the first
  1015.      character after the ignored whitespace is not a digit or a minus
  1016.      sign, this function returns 0.
  1017.  
  1018.           (string-to-number "256")
  1019.                => 256
  1020.           (string-to-number "25 is a perfect square.")
  1021.                => 25
  1022.           (string-to-number "X256")
  1023.                => 0
  1024.           (string-to-number "-4.5")
  1025.                => -4.5
  1026.  
  1027. 
  1028. File: elisp,  Node: Formatting Strings,  Next: Character Case,  Prev: String Conversion,  Up: Strings and Characters
  1029.  
  1030. Formatting Strings
  1031. ==================
  1032.  
  1033.    "Formatting" means constructing a string by substitution of computed
  1034. values at various places in a constant string.  This string controls
  1035. how the other values are printed as well as where they appear; it is
  1036. called a "format string".
  1037.  
  1038.    Formatting is often useful for computing messages to be displayed.
  1039. In fact, the functions `message' and `error' provide the same
  1040. formatting feature described here; they differ from `format' only in
  1041. how they use the result of formatting.
  1042.  
  1043.  - Function: format STRING &rest OBJECTS
  1044.      This function returns a new string that is made by copying STRING
  1045.      and then replacing any format specification in the copy with
  1046.      encodings of the corresponding OBJECTS.  The arguments OBJECTS are
  1047.      the computed values to be formatted.
  1048.  
  1049.    A format specification is a sequence of characters beginning with a
  1050. `%'.  Thus, if there is a `%d' in STRING, the `format' function
  1051. replaces it with the printed representation of one of the values to be
  1052. formatted (one of the arguments OBJECTS).  For example:
  1053.  
  1054.      (format "The value of fill-column is %d." fill-column)
  1055.           => "The value of fill-column is 72."
  1056.  
  1057.    If STRING contains more than one format specification, the format
  1058. specifications are matched with successive values from OBJECTS.  Thus,
  1059. the first format specification in STRING is matched with the first such
  1060. value, the second format specification is matched with the second such
  1061. value, and so on.  Any extra format specifications (those for which
  1062. there are no corresponding values) cause unpredictable behavior.  Any
  1063. extra values to be formatted will be ignored.
  1064.  
  1065.    Certain format specifications require values of particular types.
  1066. However, no error is signaled if the value actually supplied fails to
  1067. have the expected type.  Instead, the output is likely to be
  1068. meaningless.
  1069.  
  1070.    Here is a table of the characters that can follow `%' to make up a
  1071. format specification:
  1072.  
  1073. `s'
  1074.      Replace the specification with the printed representation of the
  1075.      object, made without quoting.  Thus, strings are represented by
  1076.      their contents alone, with no `"' characters, and symbols appear
  1077.      without `\' characters.
  1078.  
  1079.      If there is no corresponding object, the empty string is used.
  1080.  
  1081. `S'
  1082.      Replace the specification with the printed representation of the
  1083.      object, made with quoting.  Thus, strings are enclosed in `"'
  1084.      characters, and `\' characters appear where necessary before
  1085.      special characters.
  1086.  
  1087.      If there is no corresponding object, the empty string is used.
  1088.  
  1089. `o'
  1090.      Replace the specification with the base-eight representation of an
  1091.      integer.
  1092.  
  1093. `d'
  1094.      Replace the specification with the base-ten representation of an
  1095.      integer.
  1096.  
  1097. `x'
  1098.      Replace the specification with the base-sixteen representation of
  1099.      an integer.
  1100.  
  1101. `c'
  1102.      Replace the specification with the character which is the value
  1103.      given.
  1104.  
  1105. `e'
  1106.      Replace the specification with the exponential notation for a
  1107.      floating point number.
  1108.  
  1109. `f'
  1110.      Replace the specification with the decimal-point notation for a
  1111.      floating point number.
  1112.  
  1113. `g'
  1114.      Replace the specification with notation for a floating point
  1115.      number, using either exponential notation or decimal-point
  1116.      notation whichever is shorter.
  1117.  
  1118. `%'
  1119.      A single `%' is placed in the string.  This format specification is
  1120.      unusual in that it does not use a value.  For example, `(format "%%
  1121.      %d" 30)' returns `"% 30"'.
  1122.  
  1123.    Any other format character results in an `Invalid format operation'
  1124. error.
  1125.  
  1126.    Here are several examples:
  1127.  
  1128.      (format "The name of this buffer is %s." (buffer-name))
  1129.           => "The name of this buffer is strings.texi."
  1130.      
  1131.      (format "The buffer object prints as %s." (current-buffer))
  1132.           => "The buffer object prints as #<buffer strings.texi>."
  1133.      
  1134.      (format "The octal value of 18 is %o,
  1135.               and the hex value is %x." 18 18)
  1136.           => "The octal value of 18 is 22,
  1137.               and the hex value is 12."
  1138.  
  1139.    All the specification characters allow an optional numeric prefix
  1140. between the `%' and the character.  The optional numeric prefix defines
  1141. the minimum width for the object.  If the printed representation of the
  1142. object contains fewer characters than this, then it is padded.  The
  1143. padding is on the left if the prefix is positive (or starts with zero)
  1144. and on the right if the prefix is negative.  The padding character is
  1145. normally a space, but if the numeric prefix starts with a zero, zeros
  1146. are used for padding.
  1147.  
  1148.      (format "%06d will be padded on the left with zeros" 123)
  1149.           => "000123 will be padded on the left with zeros"
  1150.      
  1151.      (format "%-6d will be padded on the right" 123)
  1152.           => "123    will be padded on the right"
  1153.  
  1154.    `format' never truncates an object's printed representation, no
  1155. matter what width you specify.  Thus, you can use a numeric prefix to
  1156. specify a minimum spacing between columns with no risk of losing
  1157. information.
  1158.  
  1159.    In the following three examples, `%7s' specifies a minimum width of
  1160. 7.  In the first case, the string inserted in place of `%7s' has only 3
  1161. letters, so 4 blank spaces are inserted for padding.  In the second
  1162. case, the string `"specification"' is 13 letters wide but is not
  1163. truncated.  In the third case, the padding is on the right.
  1164.  
  1165.      (format "The word `%7s' actually has %d letters in it." "foo"
  1166.              (length "foo"))
  1167.           => "The word `    foo' actually has 3 letters in it."
  1168.  
  1169.      (format "The word `%7s' actually has %d letters in it."
  1170.              "specification"
  1171.              (length "specification"))
  1172.           => "The word `specification' actually has 13 letters in it."
  1173.  
  1174.      (format "The word `%-7s' actually has %d letters in it." "foo"
  1175.              (length "foo"))
  1176.           => "The word `foo    ' actually has 3 letters in it."
  1177.  
  1178. 
  1179. File: elisp,  Node: Character Case,  Next: Case Table,  Prev: Formatting Strings,  Up: Strings and Characters
  1180.  
  1181. Character Case
  1182. ==============
  1183.  
  1184.    The character case functions change the case of single characters or
  1185. of the contents of strings.  The functions convert only alphabetic
  1186. characters (the letters `A' through `Z' and `a' through `z'); other
  1187. characters are not altered.  The functions do not modify the strings
  1188. that are passed to them as arguments.
  1189.  
  1190.    The examples below use the characters `X' and `x' which have ASCII
  1191. codes 88 and 120 respectively.
  1192.  
  1193.  - Function: downcase STRING-OR-CHAR
  1194.      This function converts a character or a string to lower case.
  1195.  
  1196.      When the argument to `downcase' is a string, the function creates
  1197.      and returns a new string in which each letter in the argument that
  1198.      is upper case is converted to lower case.  When the argument to
  1199.      `downcase' is a character, `downcase' returns the corresponding
  1200.      lower case character.  This value is an integer.  If the original
  1201.      character is lower case, or is not a letter, then the value equals
  1202.      the original character.
  1203.  
  1204.           (downcase "The cat in the hat")
  1205.                => "the cat in the hat"
  1206.           
  1207.           (downcase ?X)
  1208.                => 120
  1209.  
  1210.  - Function: upcase STRING-OR-CHAR
  1211.      This function converts a character or a string to upper case.
  1212.  
  1213.      When the argument to `upcase' is a string, the function creates
  1214.      and returns a new string in which each letter in the argument that
  1215.      is lower case is converted to upper case.
  1216.  
  1217.      When the argument to `upcase' is a character, `upcase' returns the
  1218.      corresponding upper case character.  This value is an integer.  If
  1219.      the original character is upper case, or is not a letter, then the
  1220.      value equals the original character.
  1221.  
  1222.           (upcase "The cat in the hat")
  1223.                => "THE CAT IN THE HAT"
  1224.           
  1225.           (upcase ?x)
  1226.                => 88
  1227.  
  1228.  - Function: capitalize STRING-OR-CHAR
  1229.      This function capitalizes strings or characters.  If
  1230.      STRING-OR-CHAR is a string, the function creates and returns a new
  1231.      string, whose contents are a copy of STRING-OR-CHAR in which each
  1232.      word has been capitalized.  This means that the first character of
  1233.      each word is converted to upper case, and the rest are converted
  1234.      to lower case.
  1235.  
  1236.      The definition of a word is any sequence of consecutive characters
  1237.      that are assigned to the word constituent category in the current
  1238.      syntax table (*Note Syntax Class Table::).
  1239.  
  1240.      When the argument to `capitalize' is a character, `capitalize' has
  1241.      the same result as `upcase'.
  1242.  
  1243.           (capitalize "The cat in the hat")
  1244.                => "The Cat In The Hat"
  1245.           
  1246.           (capitalize "THE 77TH-HATTED CAT")
  1247.                => "The 77th-Hatted Cat"
  1248.           
  1249.           (capitalize ?x)
  1250.                => 88
  1251.  
  1252.