string-map(3scm)
π string-map π
okay so this is from the Scheme Programmer's Manual, section 3scm, and it's literally about mapping a procedure over characters in strings. bestie, it's giving functional realness. π¦
β¨ NAME β¨
string-map β map a procedure over the characters in strings.
π LIBRARY π
(import (scheme base)) ;R7RS
πΈ SYNOPSIS πΈ
(string-map proc string1 string2 ...)
π DESCRIPTION π
string-map takes proc and applies it element-wise to the elements of the strings, then returns a string of the results, in order. no cap. β¨
If you give it more than one string and not all strings have the same length, string-map terminates when the shortest string runs out. short queen behavior, honestly. π
The dynamic order in which proc is applied to the elements of the strings is unspecified. so don't assume an order, bestie.
If multiple returns occur from string-map, the values returned by earlier returns are not mutated. that's the rule. π
π«Ά RETURN VALUES π«Ά
Returns a single string object. one string, that's it. π
π₯ EXAMPLES π₯
here's the receipts, fr fr:
(string-map char-foldcase "AbdEgH")
=> "abdegh"
(string-map
(lambda (c)
(integer->char (+ 1 (char->integer c))))
"HAL")
=> "IBM"
; Demonstrates how it ends on the shortest string
(string-map
(lambda (c k)
((if (eqv? k #) char-upcase char-downcase)
c))
"studlycaps xxx"
"ululululul")
=> "StUdLyCaPs"
π ERRORS π
bestie, these are errors, not cute little suggestions:
- It is an error if
procdoes not accept as many arguments as there are strings or does not return a single character. - It is likewise an error if there are fewer than two arguments or if one of the arguments is outside its domain.
- Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically. π
π SEE ALSO π
map(3scm) β go check that one out too. iykyk. π
β STANDARDS β
R7RS β periodt. π
π¦ HISTORY π¦
This procedure also appears in SRFI-13. iconic crossover. β¨
π AUTHORS π
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://github.com/schemedoc/manpages/.
mwah π this page is dated 2022-03-29 and the footer tag is string-map(3scm), so that's the source/version + date sign-off, bestie. π«Ά
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2022 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms