query
On this page

stringToCharacters

lib.stringToCharacters

Docs pulled from | This Revision | 13 minutes 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 "🦄"
=> [ "�" "�" "�" "�" ]
(lib.strings.stringToCharacters)

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

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