manipulating-strings/quickref.tex
changeset 285 7c4855fb8e5f
parent 217 b595f90016c5
equal deleted inserted replaced
284:55342d3c9d25 285:7c4855fb8e5f
     1 Creating a linear array:\\
     1 \textbf{Manipulating strings}
     2 {\ex \lstinline|    x = linspace(0, 2*pi, 50)|}
       
     3 
     2 
     4 Plotting two variables:\\
     3 String indexing starts from 0, like lists.
     5 {\ex \lstinline|    plot(x, sin(x))|}
       
     6 
     4 
     7 Plotting two lists of equal length x, y:\\
     5 \lstinline|s = `Hello World'|\\
     8 {\ex \lstinline|    plot(x, y)|}
     6 \lstinline|s[0:5]| gives \texttt{Hello}\\
       
     7 \lstinline|s[6:]| gives \textt{World}\\
       
     8 \lstinline|s[6::2]| gives \textt{Wrd}\\
       
     9 
       
    10 \lstinline|s.replace('e', 'a')| returns a new string with all e's
       
    11 replaced by a.  
       
    12 
       
    13 \lstinline|s.lower()| and \lstinline|s.upper()| return new strings
       
    14 with all lower and upper case letters, respectively.