StringApply

StringApply[f,string]

applies f to the code points in string.

StringApply[f]

represents an operator form of StringApply that can be applied to an expression.

Details

  • StringApply[f,string] applies f to the code points in string, as returned by Characters.
  • The function f should return a string or a list of strings when given a list of code points.
  • If f returns a list, the output is joined into a single string.
  • StringApply[f] is automatically threaded over lists, as if it had the Listable attribute.

Examples

open allclose all

Basic Examples  (5)

Use a function meant for lists on a string:

Rotate a string:

Get a random permutation of a string:

Replace all vowels:

Insert spaces between each letter:

Scope  (4)

Any function that operates on a list in its first argument may be used:

Functions created by StringApply behave as though they were Listable:

If the given function produces nested lists of strings, the list structure will be preserved:

Characters are separated using Characters instead of byte values, so encoding is preserved:

Properties & Relations  (2)

The given function is applied to a list of strings:

StringApply applies f to Characters["string"] and joins the result:

Possible Issues  (2)

The given f must produce a string or lists of strings from its output:

Validity is not determined until evaluation of StringApply[][args]:

Wolfram Research (2024), StringApply, Wolfram Language function, https://reference.wolfram.com/language/ref/StringApply.html.

Text

Wolfram Research (2024), StringApply, Wolfram Language function, https://reference.wolfram.com/language/ref/StringApply.html.

CMS

Wolfram Language. 2024. "StringApply." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/StringApply.html.

APA

Wolfram Language. (2024). StringApply. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StringApply.html

BibTeX

@misc{reference.wolfram_2024_stringapply, author="Wolfram Research", title="{StringApply}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/StringApply.html}", note=[Accessed: 07-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_stringapply, organization={Wolfram Research}, title={StringApply}, year={2024}, url={https://reference.wolfram.com/language/ref/StringApply.html}, note=[Accessed: 07-December-2024 ]}