Site Tools


pop_function

# $EPIC: pop_function.txt,v 1.6 2007/02/17 18:41:08 jnelson Exp $

Synopsis:

$pop(<variable name>)

Technical:

  • If no arguments are provided, the empty string is returned.
  • If the argument consists of only one word, it is taken as <variable name>.
  • If more than one arguments are provided, they are taken as <word list>.
  • If a <word list> is provided, the return value is the last word in <word list>. DOUBLE QUOTED WORDS ARE NOT SUPPORTED. (This may change in the future.)
  • If <variable name> is provided, <variable name> is changed by removing the last word, and the return value is the word that was removed. DOUBLE QUOTED WORDS ARE NOT SUPPORTED. (This may change in the future.)
  • If <variable name> contains only one word, the entire contents of $<variable name> are returned and the <variable name> variable is removed/unset.
  • This function does not support double-quoted words.

Practical:

Pop removes the last word from a word list, or from a word list stored in a variable. It reverses the action of $push(). If you are implementing a FIFO, you can unshift words onto the front of a variable and pop them off the back.

Returns:

The last word of <word list> or of $<variable name>.

Examples:

$pop(one two three) returns “three” assign booya one two three four $pop(booya) returns “four”, $booya is now “one two three”.

History:

This function first appeared in “+7” (post-ircII, pre-EPIC)

pop_function.txt · Last modified: 2007/02/17 18:41 by 127.0.0.1