Site Tools


insertw

# $EPIC: insertw.txt,v 1.4 2007/03/02 02:32:04 jnelson Exp $

Synopsis:

$insertw(<index> <word> <word list>)

Technical:

  • If the <index> argument is omitted the empty string is returned.
  • If the <index> argument is less than 1, then the return value is the rest of the argument list as it is passed. (<word> <word list>)
  • Otherwise, the return value is a copy of <word list> that has had <word> inserted as the <index>th word, counting from zero.
  • No words in <word list> are removed.
  • Remember that <word list> is a list of words.

Practical:

Use this function when you need to insert a word into a word list and you have a specific place in mind for it. If you use an index of 0, then it will return the arguments just as you passed them, with any spaces between <word> and <word list> included. This is similar to the $unshift() function.

Returns:

<word list> with <word> inserted as the <index>th word.

Examples:

$insertw(1 blah hi there bob) returns “hi blah there bob”

History:

This function first appeared in “plus-2” (post-ircII, pre-EPIC)

insertw.txt · Last modified: 2007/03/02 02:32 by 127.0.0.1