Drop - Maple Help

StringTools

 Take
 extract a prefix from a string
 Drop
 remove a prefix from a string

 Calling Sequence Take( s, len ) Take( s, delim ) Drop( s, len ) Drop( s, delim )

Parameters

 s - Maple string len - non-negative integer; length of prefix to extract or remove delim - string; set of characters (delimiters)

Description

 • The Take(s, len) command returns the prefix of length len from string s.
 If s has at least len characters, then the substring of s consisting of the first len characters of s is returned. That is, the string ${s}_{1..\mathrm{len}}$ is returned. If s has length less than len, then s is returned.
 • The Drop(s, len) command removes the prefix of length len from string s.
 If the length of s is greater than or equal to len, then the string ${s}_{1+\mathrm{len}..-1}$ is returned. If the length of s is less than len, then an empty string is returned.
 • If the second argument is a string delim, it is interpreted as a set of delimiting characters. In this case, the Take( s, delim ) command returns the prefix of s consisting of characters not in the string delim. The Drop( s, delim ) command returns the suffix of s consisting of characters not in the string delim.
 • Take and Drop satisfy the equation

$s=\mathrm{cat}\left(\mathrm{Take}\left(s,n\right),\mathrm{Drop}\left(s,n\right)\right)$

 for all non-negative integers n.
 • All of the StringTools package commands treat strings as (null-terminated) sequences of $8$-bit (ASCII) characters.  Thus, there is no support for multibyte character encodings, such as unicode encodings.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{seq}\left(\mathrm{Take}\left("abcde",i\right),i=0..6\right)$
 ${""}{,}{"a"}{,}{"ab"}{,}{"abc"}{,}{"abcd"}{,}{"abcde"}{,}{"abcde"}$ (1)
 > $\mathrm{seq}\left(\mathrm{Take}\left("",i\right),i=0..6\right)$
 ${""}{,}{""}{,}{""}{,}{""}{,}{""}{,}{""}{,}{""}$ (2)
 > $\mathrm{seq}\left(\mathrm{Drop}\left("abcde",i\right),i=0..6\right)$
 ${"abcde"}{,}{"bcde"}{,}{"cde"}{,}{"de"}{,}{"e"}{,}{""}{,}{""}$ (3)
 > $\mathrm{seq}\left(\mathrm{Drop}\left("",i\right),i=0..6\right)$
 ${""}{,}{""}{,}{""}{,}{""}{,}{""}{,}{""}{,}{""}$ (4)
 > $\mathrm{seq}\left(\mathrm{cat}\left(\mathrm{Take}\left("abcde",i\right),\mathrm{Drop}\left("abcde",i\right)\right),i=0..6\right)$
 ${"abcde"}{,}{"abcde"}{,}{"abcde"}{,}{"abcde"}{,}{"abcde"}{,}{"abcde"}{,}{"abcde"}$ (5)
 > $\mathrm{Take}\left("abcde","ec"\right)$
 ${"ab"}$ (6)
 > $\mathrm{Drop}\left("abcde","ec"\right)$
 ${""}$ (7)