About

The wasSwapWords function exchanges two words in a sequence of token-delimited words and returns the resulting sequence.

For example:

Say wasSwapWords('Search/For/Me', 'Search', 'Dream', '/')

will output: Dream/For/Me

Code

/*************************************************************************/
/*    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    */
/*************************************************************************/
wasSwapWords: procedure /* Swap two words in a token delimited string.   */
    Parse ARG String,AWord,BWord,Token
    If String = '' Then Return ''
    Parse VAR String Head Interpret(Token) Tail
    Select
        When Head = AWord Then Head = BWord
        When Head = BWord Then Head = AWord
        Otherwise Nop
    End
    Look = wasSwapWords(Tail,AWord,BWord,Token)
    If Look = '' Then Return Head
Return Head || Token || Look

fuss/amiga/arexx/token_delimited_words/swapwords.txt ยท Last modified: 2017/02/22 18:30 (external edit)

Access website using Tor Access website using i2p


For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy and plagiarism pages.