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: 2022/04/19 08:28 by 127.0.0.1

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


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