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.
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 all close allBasic Examples (5)
Use a function meant for lists on a string:
StringApply[Reverse, "Hello World"]StringApply[RotateLeft, "Hello World"]StringApply[RotateRight, "Hello World"]Get a random permutation of a string:
StringApply[RandomSample, "Hello World"]StringApply[ReplaceAll["a" | "e" | "i" | "o" | "u" -> "X"]]["Hello World"]Insert spaces between each letter:
StringApply[StringRiffle, "Hello World"]Scope (4)
Any function that operates on a list in its first argument may be used:
StringApply[Union, "this is a string"]StringApply[DeleteDuplicates, "this is a string"]StringApply[Sort, "this is a string"]StringApply[Permutations, "abcd"]StringApply[Subsets, "string"]StringApply[Gather, "this is a string"]Functions created by StringApply behave as though they were Listable:
MyStringReverse = StringApply[Reverse]MyStringReverse[{"cat", "dog", "fish", "coelenterate"}]If the given function produces nested lists of strings, the list structure will be preserved:
StringApply[Outer[List, #, #]&]["ooer!"]Characters are separated using Characters instead of byte values, so encoding is preserved:
StringApply[StringRiffle @* CharacterName]["猫鳥犬"]Properties & Relations (2)
The given function is applied to a list of strings:
StringApply[ToString @* ListQ]["Hello World"]StringApply[ToString @* StringQ]["Hello World"]StringApply applies f to Characters["string"] and joins the result:
StringApply[Echo]["Hello World"]StringApply[Map[Echo]]["abc"]Possible Issues (2)
The given f must produce a string or lists of strings from its output:
StringApply[ToCharacterCode]["abc"]StringApply[StringRiffle @* Map[ToString] @* Flatten @* ToCharacterCode]["abc"]Validity is not determined until evaluation of StringApply[…][args]:
f = StringApply[invalid]f["oh no!"]Related Guides
History
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_2026_stringapply, author="Wolfram Research", title="{StringApply}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/StringApply.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_stringapply, organization={Wolfram Research}, title={StringApply}, year={2024}, url={https://reference.wolfram.com/language/ref/StringApply.html}, note=[Accessed: 13-June-2026]}