query
On this page

stringToCharacters

lib.strings.stringToCharacters

Docs pulled from | This Revision | about 2 hours ago


Convert a string s to a list of characters (i.e. singleton strings). This allows you to, e.g., map a function over each character. However, note that this will likely be horribly inefficient; Nix is not a general purpose programming language. Complex string manipulations should, if appropriate, be done in a derivation. Also note that Nix treats strings as a list of bytes and thus doesn't handle unicode.

Inputs

s
1. Function argument

Type

stringToCharacters :: string -> [string]

Examples

lib.strings.stringToCharacters usage example

stringToCharacters ""
=> [ ]
stringToCharacters "abc"
=> [ "a" "b" "c" ]
stringToCharacters "🦄"
=> [ "�" "�" "�" "�" ]

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

stringToCharacters = s:
    genList (p: substring p 1 s) (stringLength s);