Skip to content

Provide an enclose builtin function for wrapping prefix and suffix #3703

Description

@yuan-y-chang

Feature request

It would be useful to have an enclose string function that prepends a prefix
and appends a suffix to every whitespace-separated string in its argument.

The function could be defined as:

enclose(prefix, suffix, s) := prepend(prefix, append(suffix, s))

For example:

enclose('systemd/', '.service', 'foo bar baz')
# → 'systemd/foo.service systemd/bar.service systemd/baz.service'

This would be a convenient shorthand for the common pattern:

prepend(prefix, append(suffix, s))

It would complement the existing prepend() and append() functions while
making it clearer that each item is being enclosed by a prefix and suffix.

The function name may be: enclose, warp, surround, etc.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions