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


/*    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
        When Head = AWord Then Head = BWord
        When Head = BWord Then Head = AWord
        Otherwise Nop
    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: 2022/04/19 09:28 (external edit)

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key

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