String Manipulation Interpreter The 2019 Stack Overflow Developer Survey Results Are InString manipulationadd commas to Numbers without String manipulationPi language interpreterBrainFlow Interpreter!Interpret /// (pronounced 'slashes')Code Golf: Gibberish EchoInterpreted InterpreterRemove more than n consecutive vowels from input stringMake a Unicorn interpreterShortest Unique Substring

Why do UK politicians seemingly ignore opinion polls on Brexit?

Falsification in Math vs Science

Ubuntu Server install with full GUI

Distributing a matrix

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Am I thawing this London Broil safely?

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?

Are there incongruent pythagorean triangles with the same perimeter and same area?

Origin of "cooter" meaning "vagina"

Who coined the term "madman theory"?

Can you compress metal and what would be the consequences?

One word riddle: Vowel in the middle

When should I buy a clipper card after flying to OAK?

What is the accessibility of a package's `Private` context variables?

Which Sci-Fi work first showed weapon of galactic-scale mass destruction?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

How to notate time signature switching consistently every measure

Is "plugging out" electronic devices an American expression?

Output the Arecibo Message

FPGA - DIY Programming

Feature engineering suggestion required

Delete all lines which don't have n characters before delimiter

If a Druid sees an animal’s corpse, can they Wild Shape into that animal?

Landlord wants to switch my lease to a "Land contract" to "get back at the city"



String Manipulation Interpreter



The 2019 Stack Overflow Developer Survey Results Are InString manipulationadd commas to Numbers without String manipulationPi language interpreterBrainFlow Interpreter!Interpret /// (pronounced 'slashes')Code Golf: Gibberish EchoInterpreted InterpreterRemove more than n consecutive vowels from input stringMake a Unicorn interpreterShortest Unique Substring










9












$begingroup$


Summary



A new string manipulation language has been made, using only the characters $+#-!*|@>! Your task is to implement an interpreter for it in as few bytes as possible.



Input



A string, which is a single line of this language. This can be taken in any reasonable way (stdin, function parameter, command line argument etc.), or as a predefined variable. If the program asks for user input, accept all user input it asks for from stdin and nothing more, see below. You may assume it is a valid program.



Output



Whatever the language would output, specifications below. You must output a string, in any reasonable way (stdout, function output, etc.), or a variable value. When the language outputs explicitly, this must go to stdout. Standard loopholes are banned.



Language Specifications



Processing and Syntax



The language has a very simple form of processing as it does only string manipulation: it starts with an empty string (""), and changes it with each term. A term is made up of one or two parts: a function (below) followed by possibly a parameter(below), which edits its behaviour. Terms are separated by pipes (|). You may assume it will not be an empty program, and no term will be empty. You should output the value at the end of the program.



Functions



The language has just 6 functions, as shown below. Each function either accepts one or zero parameters.




  • + concatenate strings (takes one string parameter, concatenates it to the current value)


  • ! reverse the character order of the current value (no parameter)


  • * repeat the string (takes one integer parameter, repeats the current value that many times)


  • - removes all occurrences of a value (takes one string parameter, removes all occurrences of it from the current value)


  • $ [pseudo-]randomly shuffles the current value (no parameter)


  • < output the current value to stdout (no parameters)

Values



These are the values that may be passed to functions, represented by regex that would match them:




  • @[^|]* a string literal, including any character other than pipes. It may be empty.


  • #[0-9]+ an integer literal


  • > the next line of stdin. If used with *, convert to integer.

Test Cases



╔════════════════════════╤═════════════╤══════════════╗
║code │input │output ║
╟────────────────────────┼─────────────┼──────────────╢
║+>|!|+@hello|*> │13 │31hello31hello║
║ │2 │ ║
╟────────────────────────┼─────────────┼──────────────╢
║+>|+@abcdefg|$ │hello │hcloeebafdlg ║
╟────────────────────────┼─────────────┼──────────────╢
║+@how areyou|-@o|-> │w │h areyu ║
╟────────────────────────┼─────────────┼──────────────╢
║+@out|<|*#3 │ │out ║
║ │ │outoutout ║
╟────────────────────────┼─────────────┼──────────────╢
║+> │what ever 345│what ever 345 ║
╟────────────────────────┼─────────────┼──────────────╢
║+@$pe<i@l|<|-@$pe<i@l|+>│A|$o $pe<!@| │$pe<i@l ║
║ │ │A|$o $pe<!@| ║
╟────────────────────────┼─────────────┼──────────────╢
║<|+>|!|< │input text | ║
║ │ │txet tupni ║
║ │ │txet tupni ║
╟────────────────────────┼─────────────┼──────────────╢
║+@># │ |># ║
╚════════════════════════╧═════════════╧══════════════╝


Note that test case 2 is random, so any permutation of the characters in it is valid. Also, the outputs in the table are seperated by newlines, but your program doesn't have to do the same. The last value in each case the the final output.



Example (Un-golfed) python interpreter



Try it online! IMO better if you run it through IDLE or whatever you use. (I golfed it down to 424 bytes after, but I'm sure you lot can do better).










share|improve this question











$endgroup$







  • 2




    $begingroup$
    Allowing input to already be in a variable is non-standard, as is allowing output to be in one.
    $endgroup$
    – Jonathan Allan
    Apr 6 at 19:10











  • $begingroup$
    Your examples seem to print a newline everytime < is encountered. Is this mandatory?
    $endgroup$
    – Embodiment of Ignorance
    Apr 6 at 20:14










  • $begingroup$
    Will the program have newlines in it? Because if it can, it invalidates Chas Brown's answer
    $endgroup$
    – Embodiment of Ignorance
    Apr 6 at 23:56






  • 2




    $begingroup$
    For your future questions, please consider avoiding cumbersome I/O formats. Limiting input to stdin costs extra bytes in some languages and doesn't bring much to the challenge.
    $endgroup$
    – Arnauld
    Apr 7 at 8:08






  • 1




    $begingroup$
    @digEmAll How's the one I just added, +@>#? I used # aswell.
    $endgroup$
    – Artemis Fowl
    Apr 7 at 18:30















9












$begingroup$


Summary



A new string manipulation language has been made, using only the characters $+#-!*|@>! Your task is to implement an interpreter for it in as few bytes as possible.



Input



A string, which is a single line of this language. This can be taken in any reasonable way (stdin, function parameter, command line argument etc.), or as a predefined variable. If the program asks for user input, accept all user input it asks for from stdin and nothing more, see below. You may assume it is a valid program.



Output



Whatever the language would output, specifications below. You must output a string, in any reasonable way (stdout, function output, etc.), or a variable value. When the language outputs explicitly, this must go to stdout. Standard loopholes are banned.



Language Specifications



Processing and Syntax



The language has a very simple form of processing as it does only string manipulation: it starts with an empty string (""), and changes it with each term. A term is made up of one or two parts: a function (below) followed by possibly a parameter(below), which edits its behaviour. Terms are separated by pipes (|). You may assume it will not be an empty program, and no term will be empty. You should output the value at the end of the program.



Functions



The language has just 6 functions, as shown below. Each function either accepts one or zero parameters.




  • + concatenate strings (takes one string parameter, concatenates it to the current value)


  • ! reverse the character order of the current value (no parameter)


  • * repeat the string (takes one integer parameter, repeats the current value that many times)


  • - removes all occurrences of a value (takes one string parameter, removes all occurrences of it from the current value)


  • $ [pseudo-]randomly shuffles the current value (no parameter)


  • < output the current value to stdout (no parameters)

Values



These are the values that may be passed to functions, represented by regex that would match them:




  • @[^|]* a string literal, including any character other than pipes. It may be empty.


  • #[0-9]+ an integer literal


  • > the next line of stdin. If used with *, convert to integer.

Test Cases



╔════════════════════════╤═════════════╤══════════════╗
║code │input │output ║
╟────────────────────────┼─────────────┼──────────────╢
║+>|!|+@hello|*> │13 │31hello31hello║
║ │2 │ ║
╟────────────────────────┼─────────────┼──────────────╢
║+>|+@abcdefg|$ │hello │hcloeebafdlg ║
╟────────────────────────┼─────────────┼──────────────╢
║+@how areyou|-@o|-> │w │h areyu ║
╟────────────────────────┼─────────────┼──────────────╢
║+@out|<|*#3 │ │out ║
║ │ │outoutout ║
╟────────────────────────┼─────────────┼──────────────╢
║+> │what ever 345│what ever 345 ║
╟────────────────────────┼─────────────┼──────────────╢
║+@$pe<i@l|<|-@$pe<i@l|+>│A|$o $pe<!@| │$pe<i@l ║
║ │ │A|$o $pe<!@| ║
╟────────────────────────┼─────────────┼──────────────╢
║<|+>|!|< │input text | ║
║ │ │txet tupni ║
║ │ │txet tupni ║
╟────────────────────────┼─────────────┼──────────────╢
║+@># │ |># ║
╚════════════════════════╧═════════════╧══════════════╝


Note that test case 2 is random, so any permutation of the characters in it is valid. Also, the outputs in the table are seperated by newlines, but your program doesn't have to do the same. The last value in each case the the final output.



Example (Un-golfed) python interpreter



Try it online! IMO better if you run it through IDLE or whatever you use. (I golfed it down to 424 bytes after, but I'm sure you lot can do better).










share|improve this question











$endgroup$







  • 2




    $begingroup$
    Allowing input to already be in a variable is non-standard, as is allowing output to be in one.
    $endgroup$
    – Jonathan Allan
    Apr 6 at 19:10











  • $begingroup$
    Your examples seem to print a newline everytime < is encountered. Is this mandatory?
    $endgroup$
    – Embodiment of Ignorance
    Apr 6 at 20:14










  • $begingroup$
    Will the program have newlines in it? Because if it can, it invalidates Chas Brown's answer
    $endgroup$
    – Embodiment of Ignorance
    Apr 6 at 23:56






  • 2




    $begingroup$
    For your future questions, please consider avoiding cumbersome I/O formats. Limiting input to stdin costs extra bytes in some languages and doesn't bring much to the challenge.
    $endgroup$
    – Arnauld
    Apr 7 at 8:08






  • 1




    $begingroup$
    @digEmAll How's the one I just added, +@>#? I used # aswell.
    $endgroup$
    – Artemis Fowl
    Apr 7 at 18:30













9












9








9


2



$begingroup$


Summary



A new string manipulation language has been made, using only the characters $+#-!*|@>! Your task is to implement an interpreter for it in as few bytes as possible.



Input



A string, which is a single line of this language. This can be taken in any reasonable way (stdin, function parameter, command line argument etc.), or as a predefined variable. If the program asks for user input, accept all user input it asks for from stdin and nothing more, see below. You may assume it is a valid program.



Output



Whatever the language would output, specifications below. You must output a string, in any reasonable way (stdout, function output, etc.), or a variable value. When the language outputs explicitly, this must go to stdout. Standard loopholes are banned.



Language Specifications



Processing and Syntax



The language has a very simple form of processing as it does only string manipulation: it starts with an empty string (""), and changes it with each term. A term is made up of one or two parts: a function (below) followed by possibly a parameter(below), which edits its behaviour. Terms are separated by pipes (|). You may assume it will not be an empty program, and no term will be empty. You should output the value at the end of the program.



Functions



The language has just 6 functions, as shown below. Each function either accepts one or zero parameters.




  • + concatenate strings (takes one string parameter, concatenates it to the current value)


  • ! reverse the character order of the current value (no parameter)


  • * repeat the string (takes one integer parameter, repeats the current value that many times)


  • - removes all occurrences of a value (takes one string parameter, removes all occurrences of it from the current value)


  • $ [pseudo-]randomly shuffles the current value (no parameter)


  • < output the current value to stdout (no parameters)

Values



These are the values that may be passed to functions, represented by regex that would match them:




  • @[^|]* a string literal, including any character other than pipes. It may be empty.


  • #[0-9]+ an integer literal


  • > the next line of stdin. If used with *, convert to integer.

Test Cases



╔════════════════════════╤═════════════╤══════════════╗
║code │input │output ║
╟────────────────────────┼─────────────┼──────────────╢
║+>|!|+@hello|*> │13 │31hello31hello║
║ │2 │ ║
╟────────────────────────┼─────────────┼──────────────╢
║+>|+@abcdefg|$ │hello │hcloeebafdlg ║
╟────────────────────────┼─────────────┼──────────────╢
║+@how areyou|-@o|-> │w │h areyu ║
╟────────────────────────┼─────────────┼──────────────╢
║+@out|<|*#3 │ │out ║
║ │ │outoutout ║
╟────────────────────────┼─────────────┼──────────────╢
║+> │what ever 345│what ever 345 ║
╟────────────────────────┼─────────────┼──────────────╢
║+@$pe<i@l|<|-@$pe<i@l|+>│A|$o $pe<!@| │$pe<i@l ║
║ │ │A|$o $pe<!@| ║
╟────────────────────────┼─────────────┼──────────────╢
║<|+>|!|< │input text | ║
║ │ │txet tupni ║
║ │ │txet tupni ║
╟────────────────────────┼─────────────┼──────────────╢
║+@># │ |># ║
╚════════════════════════╧═════════════╧══════════════╝


Note that test case 2 is random, so any permutation of the characters in it is valid. Also, the outputs in the table are seperated by newlines, but your program doesn't have to do the same. The last value in each case the the final output.



Example (Un-golfed) python interpreter



Try it online! IMO better if you run it through IDLE or whatever you use. (I golfed it down to 424 bytes after, but I'm sure you lot can do better).










share|improve this question











$endgroup$




Summary



A new string manipulation language has been made, using only the characters $+#-!*|@>! Your task is to implement an interpreter for it in as few bytes as possible.



Input



A string, which is a single line of this language. This can be taken in any reasonable way (stdin, function parameter, command line argument etc.), or as a predefined variable. If the program asks for user input, accept all user input it asks for from stdin and nothing more, see below. You may assume it is a valid program.



Output



Whatever the language would output, specifications below. You must output a string, in any reasonable way (stdout, function output, etc.), or a variable value. When the language outputs explicitly, this must go to stdout. Standard loopholes are banned.



Language Specifications



Processing and Syntax



The language has a very simple form of processing as it does only string manipulation: it starts with an empty string (""), and changes it with each term. A term is made up of one or two parts: a function (below) followed by possibly a parameter(below), which edits its behaviour. Terms are separated by pipes (|). You may assume it will not be an empty program, and no term will be empty. You should output the value at the end of the program.



Functions



The language has just 6 functions, as shown below. Each function either accepts one or zero parameters.




  • + concatenate strings (takes one string parameter, concatenates it to the current value)


  • ! reverse the character order of the current value (no parameter)


  • * repeat the string (takes one integer parameter, repeats the current value that many times)


  • - removes all occurrences of a value (takes one string parameter, removes all occurrences of it from the current value)


  • $ [pseudo-]randomly shuffles the current value (no parameter)


  • < output the current value to stdout (no parameters)

Values



These are the values that may be passed to functions, represented by regex that would match them:




  • @[^|]* a string literal, including any character other than pipes. It may be empty.


  • #[0-9]+ an integer literal


  • > the next line of stdin. If used with *, convert to integer.

Test Cases



╔════════════════════════╤═════════════╤══════════════╗
║code │input │output ║
╟────────────────────────┼─────────────┼──────────────╢
║+>|!|+@hello|*> │13 │31hello31hello║
║ │2 │ ║
╟────────────────────────┼─────────────┼──────────────╢
║+>|+@abcdefg|$ │hello │hcloeebafdlg ║
╟────────────────────────┼─────────────┼──────────────╢
║+@how areyou|-@o|-> │w │h areyu ║
╟────────────────────────┼─────────────┼──────────────╢
║+@out|<|*#3 │ │out ║
║ │ │outoutout ║
╟────────────────────────┼─────────────┼──────────────╢
║+> │what ever 345│what ever 345 ║
╟────────────────────────┼─────────────┼──────────────╢
║+@$pe<i@l|<|-@$pe<i@l|+>│A|$o $pe<!@| │$pe<i@l ║
║ │ │A|$o $pe<!@| ║
╟────────────────────────┼─────────────┼──────────────╢
║<|+>|!|< │input text | ║
║ │ │txet tupni ║
║ │ │txet tupni ║
╟────────────────────────┼─────────────┼──────────────╢
║+@># │ |># ║
╚════════════════════════╧═════════════╧══════════════╝


Note that test case 2 is random, so any permutation of the characters in it is valid. Also, the outputs in the table are seperated by newlines, but your program doesn't have to do the same. The last value in each case the the final output.



Example (Un-golfed) python interpreter



Try it online! IMO better if you run it through IDLE or whatever you use. (I golfed it down to 424 bytes after, but I'm sure you lot can do better).







code-golf string interpreter






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 7 at 18:29







Artemis Fowl

















asked Apr 6 at 17:29









Artemis FowlArtemis Fowl

23610




23610







  • 2




    $begingroup$
    Allowing input to already be in a variable is non-standard, as is allowing output to be in one.
    $endgroup$
    – Jonathan Allan
    Apr 6 at 19:10











  • $begingroup$
    Your examples seem to print a newline everytime < is encountered. Is this mandatory?
    $endgroup$
    – Embodiment of Ignorance
    Apr 6 at 20:14










  • $begingroup$
    Will the program have newlines in it? Because if it can, it invalidates Chas Brown's answer
    $endgroup$
    – Embodiment of Ignorance
    Apr 6 at 23:56






  • 2




    $begingroup$
    For your future questions, please consider avoiding cumbersome I/O formats. Limiting input to stdin costs extra bytes in some languages and doesn't bring much to the challenge.
    $endgroup$
    – Arnauld
    Apr 7 at 8:08






  • 1




    $begingroup$
    @digEmAll How's the one I just added, +@>#? I used # aswell.
    $endgroup$
    – Artemis Fowl
    Apr 7 at 18:30












  • 2




    $begingroup$
    Allowing input to already be in a variable is non-standard, as is allowing output to be in one.
    $endgroup$
    – Jonathan Allan
    Apr 6 at 19:10











  • $begingroup$
    Your examples seem to print a newline everytime < is encountered. Is this mandatory?
    $endgroup$
    – Embodiment of Ignorance
    Apr 6 at 20:14










  • $begingroup$
    Will the program have newlines in it? Because if it can, it invalidates Chas Brown's answer
    $endgroup$
    – Embodiment of Ignorance
    Apr 6 at 23:56






  • 2




    $begingroup$
    For your future questions, please consider avoiding cumbersome I/O formats. Limiting input to stdin costs extra bytes in some languages and doesn't bring much to the challenge.
    $endgroup$
    – Arnauld
    Apr 7 at 8:08






  • 1




    $begingroup$
    @digEmAll How's the one I just added, +@>#? I used # aswell.
    $endgroup$
    – Artemis Fowl
    Apr 7 at 18:30







2




2




$begingroup$
Allowing input to already be in a variable is non-standard, as is allowing output to be in one.
$endgroup$
– Jonathan Allan
Apr 6 at 19:10





$begingroup$
Allowing input to already be in a variable is non-standard, as is allowing output to be in one.
$endgroup$
– Jonathan Allan
Apr 6 at 19:10













$begingroup$
Your examples seem to print a newline everytime < is encountered. Is this mandatory?
$endgroup$
– Embodiment of Ignorance
Apr 6 at 20:14




$begingroup$
Your examples seem to print a newline everytime < is encountered. Is this mandatory?
$endgroup$
– Embodiment of Ignorance
Apr 6 at 20:14












$begingroup$
Will the program have newlines in it? Because if it can, it invalidates Chas Brown's answer
$endgroup$
– Embodiment of Ignorance
Apr 6 at 23:56




$begingroup$
Will the program have newlines in it? Because if it can, it invalidates Chas Brown's answer
$endgroup$
– Embodiment of Ignorance
Apr 6 at 23:56




2




2




$begingroup$
For your future questions, please consider avoiding cumbersome I/O formats. Limiting input to stdin costs extra bytes in some languages and doesn't bring much to the challenge.
$endgroup$
– Arnauld
Apr 7 at 8:08




$begingroup$
For your future questions, please consider avoiding cumbersome I/O formats. Limiting input to stdin costs extra bytes in some languages and doesn't bring much to the challenge.
$endgroup$
– Arnauld
Apr 7 at 8:08




1




1




$begingroup$
@digEmAll How's the one I just added, +@>#? I used # aswell.
$endgroup$
– Artemis Fowl
Apr 7 at 18:30




$begingroup$
@digEmAll How's the one I just added, +@>#? I used # aswell.
$endgroup$
– Artemis Fowl
Apr 7 at 18:30










4 Answers
4






active

oldest

votes


















4












$begingroup$


R, 287 286 273 bytes





function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)for(k in el(strsplit(C,'\


Try it online!



  • -1 thanks to @Kirill L.

Unrolled code and explanation :



function(C)')) # split C by pipe '





share|improve this answer











$endgroup$




















    3












    $begingroup$


    Python 2, 215 219 209 208 bytes





    from random import*
    I=raw_input;o=''
    for t in I().split('|'):p=t[1:]=='>'and I()or t[2:];exec"o=o[::-1] o*=int(p) 0 print(o) o=''.join(sample(o,len(o))) o=o.replace(p,'') o+=p".split()[ord(t[0])*5%11]
    print o


    Try it online!



    -4 because raw_input is required.



    9 bytes thanks to Embodiment of Ignorance;
    1 byte from Ascii-only.






    share|improve this answer











    $endgroup$












    • $begingroup$
      Input other than the program must be from stdin, as specified in the question.
      $endgroup$
      – Artemis Fowl
      Apr 6 at 21:38










    • $begingroup$
      I use Python 3, but as far as I was aware, that usage of input requires raw_input. Correct me if I am wrong..
      $endgroup$
      – Artemis Fowl
      Apr 6 at 21:42










    • $begingroup$
      According to Py 2.7 docs: input([prompt]) Equivalent to eval(raw_input(prompt)). This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised.
      $endgroup$
      – Artemis Fowl
      Apr 6 at 21:48










    • $begingroup$
      So, the issue you're raising is something like here, where the input strings would need to be quoted - rather than unquoted as in a 'true' stdin situation. Again, usually the I/O rules are a bit lax; but I will modify.
      $endgroup$
      – Chas Brown
      Apr 6 at 21:59











    • $begingroup$
      Thanks for changing. You could save a few bytes by changing to Python 3 and using your old code + 3 bytes for brackets, but... +1 anyways
      $endgroup$
      – Artemis Fowl
      Apr 6 at 22:03



















    3












    $begingroup$


    Ruby -palF|, 146 142 bytes





    r='';$F.mapx=i[1]!=?>?i[2..-1]:gets.chomp;eval %w[r.reverse! r*=x.to_i 0 $><<r r=r.chars.shuffle*'' r.gsub!x,'' r+=x][i[0].ord*5%11];$_=r


    Try it online!



    Port of Chas Brown's Python answer. Does not print newlines after output.



    As usual, Ruby 2.6 version will be 2 bytes shorter with endless range indexing (i[2..]).






    share|improve this answer











    $endgroup$




















      2












      $begingroup$


      C# (Visual C# Interactive Compiler), 305 bytes





      a=>string s="",d,g;foreach(var c in a.Split('


      Try it online!






      share|improve this answer











      $endgroup$













        Your Answer





        StackExchange.ifUsing("editor", function ()
        return StackExchange.using("mathjaxEditing", function ()
        StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
        StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
        );
        );
        , "mathjax-editing");

        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "200"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182764%2fstring-manipulation-interpreter%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        4












        $begingroup$


        R, 287 286 273 bytes





        function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)for(k in el(strsplit(C,'\


        Try it online!



        • -1 thanks to @Kirill L.

        Unrolled code and explanation :



        function(C)')) # split C by pipe '





        share|improve this answer











        $endgroup$

















          4












          $begingroup$


          R, 287 286 273 bytes





          function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)for(k in el(strsplit(C,'\


          Try it online!



          • -1 thanks to @Kirill L.

          Unrolled code and explanation :



          function(C)')) # split C by pipe '





          share|improve this answer











          $endgroup$















            4












            4








            4





            $begingroup$


            R, 287 286 273 bytes





            function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)for(k in el(strsplit(C,'\


            Try it online!



            • -1 thanks to @Kirill L.

            Unrolled code and explanation :



            function(C)')) # split C by pipe '





            share|improve this answer











            $endgroup$




            R, 287 286 273 bytes





            function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)for(k in el(strsplit(C,'\


            Try it online!



            • -1 thanks to @Kirill L.

            Unrolled code and explanation :



            function(C)')) # split C by pipe '






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 2 days ago

























            answered Apr 7 at 13:47









            digEmAlldigEmAll

            3,544515




            3,544515





















                3












                $begingroup$


                Python 2, 215 219 209 208 bytes





                from random import*
                I=raw_input;o=''
                for t in I().split('|'):p=t[1:]=='>'and I()or t[2:];exec"o=o[::-1] o*=int(p) 0 print(o) o=''.join(sample(o,len(o))) o=o.replace(p,'') o+=p".split()[ord(t[0])*5%11]
                print o


                Try it online!



                -4 because raw_input is required.



                9 bytes thanks to Embodiment of Ignorance;
                1 byte from Ascii-only.






                share|improve this answer











                $endgroup$












                • $begingroup$
                  Input other than the program must be from stdin, as specified in the question.
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:38










                • $begingroup$
                  I use Python 3, but as far as I was aware, that usage of input requires raw_input. Correct me if I am wrong..
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:42










                • $begingroup$
                  According to Py 2.7 docs: input([prompt]) Equivalent to eval(raw_input(prompt)). This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised.
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:48










                • $begingroup$
                  So, the issue you're raising is something like here, where the input strings would need to be quoted - rather than unquoted as in a 'true' stdin situation. Again, usually the I/O rules are a bit lax; but I will modify.
                  $endgroup$
                  – Chas Brown
                  Apr 6 at 21:59











                • $begingroup$
                  Thanks for changing. You could save a few bytes by changing to Python 3 and using your old code + 3 bytes for brackets, but... +1 anyways
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 22:03
















                3












                $begingroup$


                Python 2, 215 219 209 208 bytes





                from random import*
                I=raw_input;o=''
                for t in I().split('|'):p=t[1:]=='>'and I()or t[2:];exec"o=o[::-1] o*=int(p) 0 print(o) o=''.join(sample(o,len(o))) o=o.replace(p,'') o+=p".split()[ord(t[0])*5%11]
                print o


                Try it online!



                -4 because raw_input is required.



                9 bytes thanks to Embodiment of Ignorance;
                1 byte from Ascii-only.






                share|improve this answer











                $endgroup$












                • $begingroup$
                  Input other than the program must be from stdin, as specified in the question.
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:38










                • $begingroup$
                  I use Python 3, but as far as I was aware, that usage of input requires raw_input. Correct me if I am wrong..
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:42










                • $begingroup$
                  According to Py 2.7 docs: input([prompt]) Equivalent to eval(raw_input(prompt)). This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised.
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:48










                • $begingroup$
                  So, the issue you're raising is something like here, where the input strings would need to be quoted - rather than unquoted as in a 'true' stdin situation. Again, usually the I/O rules are a bit lax; but I will modify.
                  $endgroup$
                  – Chas Brown
                  Apr 6 at 21:59











                • $begingroup$
                  Thanks for changing. You could save a few bytes by changing to Python 3 and using your old code + 3 bytes for brackets, but... +1 anyways
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 22:03














                3












                3








                3





                $begingroup$


                Python 2, 215 219 209 208 bytes





                from random import*
                I=raw_input;o=''
                for t in I().split('|'):p=t[1:]=='>'and I()or t[2:];exec"o=o[::-1] o*=int(p) 0 print(o) o=''.join(sample(o,len(o))) o=o.replace(p,'') o+=p".split()[ord(t[0])*5%11]
                print o


                Try it online!



                -4 because raw_input is required.



                9 bytes thanks to Embodiment of Ignorance;
                1 byte from Ascii-only.






                share|improve this answer











                $endgroup$




                Python 2, 215 219 209 208 bytes





                from random import*
                I=raw_input;o=''
                for t in I().split('|'):p=t[1:]=='>'and I()or t[2:];exec"o=o[::-1] o*=int(p) 0 print(o) o=''.join(sample(o,len(o))) o=o.replace(p,'') o+=p".split()[ord(t[0])*5%11]
                print o


                Try it online!



                -4 because raw_input is required.



                9 bytes thanks to Embodiment of Ignorance;
                1 byte from Ascii-only.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 7 at 3:48

























                answered Apr 6 at 21:33









                Chas BrownChas Brown

                5,2291523




                5,2291523











                • $begingroup$
                  Input other than the program must be from stdin, as specified in the question.
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:38










                • $begingroup$
                  I use Python 3, but as far as I was aware, that usage of input requires raw_input. Correct me if I am wrong..
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:42










                • $begingroup$
                  According to Py 2.7 docs: input([prompt]) Equivalent to eval(raw_input(prompt)). This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised.
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:48










                • $begingroup$
                  So, the issue you're raising is something like here, where the input strings would need to be quoted - rather than unquoted as in a 'true' stdin situation. Again, usually the I/O rules are a bit lax; but I will modify.
                  $endgroup$
                  – Chas Brown
                  Apr 6 at 21:59











                • $begingroup$
                  Thanks for changing. You could save a few bytes by changing to Python 3 and using your old code + 3 bytes for brackets, but... +1 anyways
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 22:03

















                • $begingroup$
                  Input other than the program must be from stdin, as specified in the question.
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:38










                • $begingroup$
                  I use Python 3, but as far as I was aware, that usage of input requires raw_input. Correct me if I am wrong..
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:42










                • $begingroup$
                  According to Py 2.7 docs: input([prompt]) Equivalent to eval(raw_input(prompt)). This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised.
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 21:48










                • $begingroup$
                  So, the issue you're raising is something like here, where the input strings would need to be quoted - rather than unquoted as in a 'true' stdin situation. Again, usually the I/O rules are a bit lax; but I will modify.
                  $endgroup$
                  – Chas Brown
                  Apr 6 at 21:59











                • $begingroup$
                  Thanks for changing. You could save a few bytes by changing to Python 3 and using your old code + 3 bytes for brackets, but... +1 anyways
                  $endgroup$
                  – Artemis Fowl
                  Apr 6 at 22:03
















                $begingroup$
                Input other than the program must be from stdin, as specified in the question.
                $endgroup$
                – Artemis Fowl
                Apr 6 at 21:38




                $begingroup$
                Input other than the program must be from stdin, as specified in the question.
                $endgroup$
                – Artemis Fowl
                Apr 6 at 21:38












                $begingroup$
                I use Python 3, but as far as I was aware, that usage of input requires raw_input. Correct me if I am wrong..
                $endgroup$
                – Artemis Fowl
                Apr 6 at 21:42




                $begingroup$
                I use Python 3, but as far as I was aware, that usage of input requires raw_input. Correct me if I am wrong..
                $endgroup$
                – Artemis Fowl
                Apr 6 at 21:42












                $begingroup$
                According to Py 2.7 docs: input([prompt]) Equivalent to eval(raw_input(prompt)). This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised.
                $endgroup$
                – Artemis Fowl
                Apr 6 at 21:48




                $begingroup$
                According to Py 2.7 docs: input([prompt]) Equivalent to eval(raw_input(prompt)). This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised.
                $endgroup$
                – Artemis Fowl
                Apr 6 at 21:48












                $begingroup$
                So, the issue you're raising is something like here, where the input strings would need to be quoted - rather than unquoted as in a 'true' stdin situation. Again, usually the I/O rules are a bit lax; but I will modify.
                $endgroup$
                – Chas Brown
                Apr 6 at 21:59





                $begingroup$
                So, the issue you're raising is something like here, where the input strings would need to be quoted - rather than unquoted as in a 'true' stdin situation. Again, usually the I/O rules are a bit lax; but I will modify.
                $endgroup$
                – Chas Brown
                Apr 6 at 21:59













                $begingroup$
                Thanks for changing. You could save a few bytes by changing to Python 3 and using your old code + 3 bytes for brackets, but... +1 anyways
                $endgroup$
                – Artemis Fowl
                Apr 6 at 22:03





                $begingroup$
                Thanks for changing. You could save a few bytes by changing to Python 3 and using your old code + 3 bytes for brackets, but... +1 anyways
                $endgroup$
                – Artemis Fowl
                Apr 6 at 22:03












                3












                $begingroup$


                Ruby -palF|, 146 142 bytes





                r='';$F.mapx=i[1]!=?>?i[2..-1]:gets.chomp;eval %w[r.reverse! r*=x.to_i 0 $><<r r=r.chars.shuffle*'' r.gsub!x,'' r+=x][i[0].ord*5%11];$_=r


                Try it online!



                Port of Chas Brown's Python answer. Does not print newlines after output.



                As usual, Ruby 2.6 version will be 2 bytes shorter with endless range indexing (i[2..]).






                share|improve this answer











                $endgroup$

















                  3












                  $begingroup$


                  Ruby -palF|, 146 142 bytes





                  r='';$F.mapx=i[1]!=?>?i[2..-1]:gets.chomp;eval %w[r.reverse! r*=x.to_i 0 $><<r r=r.chars.shuffle*'' r.gsub!x,'' r+=x][i[0].ord*5%11];$_=r


                  Try it online!



                  Port of Chas Brown's Python answer. Does not print newlines after output.



                  As usual, Ruby 2.6 version will be 2 bytes shorter with endless range indexing (i[2..]).






                  share|improve this answer











                  $endgroup$















                    3












                    3








                    3





                    $begingroup$


                    Ruby -palF|, 146 142 bytes





                    r='';$F.mapx=i[1]!=?>?i[2..-1]:gets.chomp;eval %w[r.reverse! r*=x.to_i 0 $><<r r=r.chars.shuffle*'' r.gsub!x,'' r+=x][i[0].ord*5%11];$_=r


                    Try it online!



                    Port of Chas Brown's Python answer. Does not print newlines after output.



                    As usual, Ruby 2.6 version will be 2 bytes shorter with endless range indexing (i[2..]).






                    share|improve this answer











                    $endgroup$




                    Ruby -palF|, 146 142 bytes





                    r='';$F.mapx=i[1]!=?>?i[2..-1]:gets.chomp;eval %w[r.reverse! r*=x.to_i 0 $><<r r=r.chars.shuffle*'' r.gsub!x,'' r+=x][i[0].ord*5%11];$_=r


                    Try it online!



                    Port of Chas Brown's Python answer. Does not print newlines after output.



                    As usual, Ruby 2.6 version will be 2 bytes shorter with endless range indexing (i[2..]).







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Apr 7 at 14:22

























                    answered Apr 7 at 11:25









                    Kirill L.Kirill L.

                    6,1081527




                    6,1081527





















                        2












                        $begingroup$


                        C# (Visual C# Interactive Compiler), 305 bytes





                        a=>string s="",d,g;foreach(var c in a.Split('


                        Try it online!






                        share|improve this answer











                        $endgroup$

















                          2












                          $begingroup$


                          C# (Visual C# Interactive Compiler), 305 bytes





                          a=>string s="",d,g;foreach(var c in a.Split('


                          Try it online!






                          share|improve this answer











                          $endgroup$















                            2












                            2








                            2





                            $begingroup$


                            C# (Visual C# Interactive Compiler), 305 bytes





                            a=>string s="",d,g;foreach(var c in a.Split('


                            Try it online!






                            share|improve this answer











                            $endgroup$




                            C# (Visual C# Interactive Compiler), 305 bytes





                            a=>string s="",d,g;foreach(var c in a.Split('


                            Try it online!







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Apr 6 at 21:29

























                            answered Apr 6 at 20:17









                            Embodiment of IgnoranceEmbodiment of Ignorance

                            2,926127




                            2,926127



























                                draft saved

                                draft discarded
















































                                If this is an answer to a challenge…



                                • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                  Explanations of your answer make it more interesting to read and are very much encouraged.


                                • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                More generally…



                                • …Please make sure to answer the question and provide sufficient detail.


                                • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182764%2fstring-manipulation-interpreter%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

                                Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070

                                Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020