Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow MAP-EACH to work on any-string! #49

Open
Siskin-Bot opened this issue Feb 15, 2020 · 0 comments
Open

Allow MAP-EACH to work on any-string! #49

Siskin-Bot opened this issue Feb 15, 2020 · 0 comments

Comments

@Siskin-Bot
Copy link

Submitted by: fork

It would be nice if map-each could take a string in and give a string back.

>> map-each ch "abc<def>ghi&jkl" [
    switch/default ch [
        #"<" ["<"]
        #">" [">"]
        #"&" ["&"]
    ] [
        ch
    ]
]
== "abc<def>ghi&"

The concept here would be that it would take in a string, give it to you character-by-character, and then you could produce a character or string to add to what ultimately becomes a string output.


Imported from: CureCode [ Version: r3 master Type: Wish Platform: All Category: Native Reproduce: Always Fixed-in:none ]
Imported from: metaeducation/rebol-issues#2157

Comments:

Rebolbot commented on Jun 22, 2014:

Submitted by: BrianH

MAP-EACH should work on strings, but shouldn't by default return a string, it should continue to return a block; that would make it more useful for polymorphic code. Making it return a string should be done with an /as option (similar to Oldes/Rebol-issues#724, with errors triggered for incompatible types), or with an /into option (#709); that would also make it more useful for polymorphic code. Why should the type of the input constrain the output type, when we could have controlled conversion? See Oldes/Rebol-issues#2081 for an example of this kind of controlled conversion.


Rebolbot added the Type.wish on Jan 12, 2016


Hostilefork commented on Oct 8, 2018:

Ren-C follows the convention of always producing a BLOCK!, while accepting other series types as input. This leans on some of the justifications given for getting rid of the /INTO refinement....accepting the generality of blocks and looking for other means of optimization.


Hostilefork added the Ren.resolved on Oct 8, 2018


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

No branches or pull requests

1 participant