String Manipulation InterpreterString 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

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

Is the language <p,n> belongs to NP class?

GPS Rollover on Android Smartphones

Theorems that impeded progress

Type 1 Error & Type 2 Error's pregnancy test analogy: is it legit?

Prevent a directory in /tmp from being deleted

Shell script not opening as desktop application

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

What do you call a Matrix-like slowdown and camera movement effect?

What is the offset in a seaplane's hull?

How much RAM could one put in a typical 80386 setup?

Why Is Death Allowed In the Matrix?

A function which translates a sentence to title-case

Has the BBC provided arguments for saying Brexit being cancelled is unlikely?

The magic money tree problem

Today is the Center

Modeling an IPv4 Address

Infinite past with a beginning?

What defenses are there against being summoned by the Gate spell?

If two metric spaces are topologically equivalent (homeomorphic) imply that they are complete?

Is it unprofessional to ask if a job posting on GlassDoor is real?

How do I create uniquely male characters?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

Why don't electron-positron collisions release infinite energy?



String Manipulation Interpreter


String 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













8












$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 │ ║
║ │2 │31hello31hello║
╟────────────────────────┼─────────────┼──────────────╢
║+>|+@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<!@| ║
╚════════════════════════╧═════════════╧══════════════╝


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
    21 hours ago











  • $begingroup$
    Are we allowed to take in a generator function instead of an array/list for the input?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago











  • $begingroup$
    Also, for <, if our answer is a function that returns a value, should I print in the middle of the function and return the final string?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago










  • $begingroup$
    Your examples seem to print a newline everytime < is encountered. Is this mandatory?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago






  • 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
    8 hours ago















8












$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 │ ║
║ │2 │31hello31hello║
╟────────────────────────┼─────────────┼──────────────╢
║+>|+@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<!@| ║
╚════════════════════════╧═════════════╧══════════════╝


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
    21 hours ago











  • $begingroup$
    Are we allowed to take in a generator function instead of an array/list for the input?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago











  • $begingroup$
    Also, for <, if our answer is a function that returns a value, should I print in the middle of the function and return the final string?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago










  • $begingroup$
    Your examples seem to print a newline everytime < is encountered. Is this mandatory?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago






  • 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
    8 hours ago













8












8








8


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 │ ║
║ │2 │31hello31hello║
╟────────────────────────┼─────────────┼──────────────╢
║+>|+@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<!@| ║
╚════════════════════════╧═════════════╧══════════════╝


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 │ ║
║ │2 │31hello31hello║
╟────────────────────────┼─────────────┼──────────────╢
║+>|+@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<!@| ║
╚════════════════════════╧═════════════╧══════════════╝


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 7 hours ago







Artemis Fowl

















asked 23 hours ago









Artemis FowlArtemis Fowl

2319




2319







  • 2




    $begingroup$
    Allowing input to already be in a variable is non-standard, as is allowing output to be in one.
    $endgroup$
    – Jonathan Allan
    21 hours ago











  • $begingroup$
    Are we allowed to take in a generator function instead of an array/list for the input?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago











  • $begingroup$
    Also, for <, if our answer is a function that returns a value, should I print in the middle of the function and return the final string?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago










  • $begingroup$
    Your examples seem to print a newline everytime < is encountered. Is this mandatory?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago






  • 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
    8 hours ago












  • 2




    $begingroup$
    Allowing input to already be in a variable is non-standard, as is allowing output to be in one.
    $endgroup$
    – Jonathan Allan
    21 hours ago











  • $begingroup$
    Are we allowed to take in a generator function instead of an array/list for the input?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago











  • $begingroup$
    Also, for <, if our answer is a function that returns a value, should I print in the middle of the function and return the final string?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago










  • $begingroup$
    Your examples seem to print a newline everytime < is encountered. Is this mandatory?
    $endgroup$
    – Embodiment of Ignorance
    20 hours ago






  • 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
    8 hours ago







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
21 hours ago





$begingroup$
Allowing input to already be in a variable is non-standard, as is allowing output to be in one.
$endgroup$
– Jonathan Allan
21 hours ago













$begingroup$
Are we allowed to take in a generator function instead of an array/list for the input?
$endgroup$
– Embodiment of Ignorance
20 hours ago





$begingroup$
Are we allowed to take in a generator function instead of an array/list for the input?
$endgroup$
– Embodiment of Ignorance
20 hours ago













$begingroup$
Also, for <, if our answer is a function that returns a value, should I print in the middle of the function and return the final string?
$endgroup$
– Embodiment of Ignorance
20 hours ago




$begingroup$
Also, for <, if our answer is a function that returns a value, should I print in the middle of the function and return the final string?
$endgroup$
– Embodiment of Ignorance
20 hours ago












$begingroup$
Your examples seem to print a newline everytime < is encountered. Is this mandatory?
$endgroup$
– Embodiment of Ignorance
20 hours ago




$begingroup$
Your examples seem to print a newline everytime < is encountered. Is this mandatory?
$endgroup$
– Embodiment of Ignorance
20 hours ago




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
8 hours ago




$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
8 hours ago










4 Answers
4






active

oldest

votes


















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
    18 hours ago










  • $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
    18 hours ago










  • $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
    18 hours ago










  • $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
    18 hours ago











  • $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
    18 hours ago



















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$












  • $begingroup$
    What's that in the TIO input section? Your code seems to operate the same without it... [Utterly new to C#]
    $endgroup$
    – Artemis Fowl
    19 hours ago










  • $begingroup$
    @ArtemisFowl Those were some notes I were writing, forgot to delete. Deleted now
    $endgroup$
    – Embodiment of Ignorance
    19 hours ago











  • $begingroup$
    As specified by the question (12 mins before your answer was posted), input other than the program should be taken from stdin.
    $endgroup$
    – Artemis Fowl
    19 hours ago










  • $begingroup$
    @ArtemisFowl Fixed, and saved some bytes
    $endgroup$
    – Embodiment of Ignorance
    19 hours ago


















2












$begingroup$


R, 287 bytes





function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)')))B=eval(parse(t='^.'['','(?<=.)>$'['readLines(,1)','(@;x


Try it online!



Unrolled code and explanation :



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





share|improve this answer











$endgroup$












  • $begingroup$
    A quick -1: (@|#) can be [@#]
    $endgroup$
    – Kirill L.
    1 hour ago


















1












$begingroup$


Ruby -palF|, 146 142 bytes





r='';$F.map;$_=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$













    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









    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
      18 hours ago










    • $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
      18 hours ago










    • $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
      18 hours ago










    • $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
      18 hours ago











    • $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
      18 hours ago
















    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
      18 hours ago










    • $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
      18 hours ago










    • $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
      18 hours ago










    • $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
      18 hours ago











    • $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
      18 hours ago














    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 12 hours ago

























    answered 18 hours ago









    Chas BrownChas Brown

    5,1891523




    5,1891523











    • $begingroup$
      Input other than the program must be from stdin, as specified in the question.
      $endgroup$
      – Artemis Fowl
      18 hours ago










    • $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
      18 hours ago










    • $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
      18 hours ago










    • $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
      18 hours ago











    • $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
      18 hours ago

















    • $begingroup$
      Input other than the program must be from stdin, as specified in the question.
      $endgroup$
      – Artemis Fowl
      18 hours ago










    • $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
      18 hours ago










    • $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
      18 hours ago










    • $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
      18 hours ago











    • $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
      18 hours ago
















    $begingroup$
    Input other than the program must be from stdin, as specified in the question.
    $endgroup$
    – Artemis Fowl
    18 hours ago




    $begingroup$
    Input other than the program must be from stdin, as specified in the question.
    $endgroup$
    – Artemis Fowl
    18 hours ago












    $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
    18 hours ago




    $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
    18 hours ago












    $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
    18 hours ago




    $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
    18 hours ago












    $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
    18 hours ago





    $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
    18 hours ago













    $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
    18 hours ago





    $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
    18 hours ago












    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$












    • $begingroup$
      What's that in the TIO input section? Your code seems to operate the same without it... [Utterly new to C#]
      $endgroup$
      – Artemis Fowl
      19 hours ago










    • $begingroup$
      @ArtemisFowl Those were some notes I were writing, forgot to delete. Deleted now
      $endgroup$
      – Embodiment of Ignorance
      19 hours ago











    • $begingroup$
      As specified by the question (12 mins before your answer was posted), input other than the program should be taken from stdin.
      $endgroup$
      – Artemis Fowl
      19 hours ago










    • $begingroup$
      @ArtemisFowl Fixed, and saved some bytes
      $endgroup$
      – Embodiment of Ignorance
      19 hours ago















    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$












    • $begingroup$
      What's that in the TIO input section? Your code seems to operate the same without it... [Utterly new to C#]
      $endgroup$
      – Artemis Fowl
      19 hours ago










    • $begingroup$
      @ArtemisFowl Those were some notes I were writing, forgot to delete. Deleted now
      $endgroup$
      – Embodiment of Ignorance
      19 hours ago











    • $begingroup$
      As specified by the question (12 mins before your answer was posted), input other than the program should be taken from stdin.
      $endgroup$
      – Artemis Fowl
      19 hours ago










    • $begingroup$
      @ArtemisFowl Fixed, and saved some bytes
      $endgroup$
      – Embodiment of Ignorance
      19 hours ago













    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 19 hours ago

























    answered 20 hours ago









    Embodiment of IgnoranceEmbodiment of Ignorance

    2,788127




    2,788127











    • $begingroup$
      What's that in the TIO input section? Your code seems to operate the same without it... [Utterly new to C#]
      $endgroup$
      – Artemis Fowl
      19 hours ago










    • $begingroup$
      @ArtemisFowl Those were some notes I were writing, forgot to delete. Deleted now
      $endgroup$
      – Embodiment of Ignorance
      19 hours ago











    • $begingroup$
      As specified by the question (12 mins before your answer was posted), input other than the program should be taken from stdin.
      $endgroup$
      – Artemis Fowl
      19 hours ago










    • $begingroup$
      @ArtemisFowl Fixed, and saved some bytes
      $endgroup$
      – Embodiment of Ignorance
      19 hours ago
















    • $begingroup$
      What's that in the TIO input section? Your code seems to operate the same without it... [Utterly new to C#]
      $endgroup$
      – Artemis Fowl
      19 hours ago










    • $begingroup$
      @ArtemisFowl Those were some notes I were writing, forgot to delete. Deleted now
      $endgroup$
      – Embodiment of Ignorance
      19 hours ago











    • $begingroup$
      As specified by the question (12 mins before your answer was posted), input other than the program should be taken from stdin.
      $endgroup$
      – Artemis Fowl
      19 hours ago










    • $begingroup$
      @ArtemisFowl Fixed, and saved some bytes
      $endgroup$
      – Embodiment of Ignorance
      19 hours ago















    $begingroup$
    What's that in the TIO input section? Your code seems to operate the same without it... [Utterly new to C#]
    $endgroup$
    – Artemis Fowl
    19 hours ago




    $begingroup$
    What's that in the TIO input section? Your code seems to operate the same without it... [Utterly new to C#]
    $endgroup$
    – Artemis Fowl
    19 hours ago












    $begingroup$
    @ArtemisFowl Those were some notes I were writing, forgot to delete. Deleted now
    $endgroup$
    – Embodiment of Ignorance
    19 hours ago





    $begingroup$
    @ArtemisFowl Those were some notes I were writing, forgot to delete. Deleted now
    $endgroup$
    – Embodiment of Ignorance
    19 hours ago













    $begingroup$
    As specified by the question (12 mins before your answer was posted), input other than the program should be taken from stdin.
    $endgroup$
    – Artemis Fowl
    19 hours ago




    $begingroup$
    As specified by the question (12 mins before your answer was posted), input other than the program should be taken from stdin.
    $endgroup$
    – Artemis Fowl
    19 hours ago












    $begingroup$
    @ArtemisFowl Fixed, and saved some bytes
    $endgroup$
    – Embodiment of Ignorance
    19 hours ago




    $begingroup$
    @ArtemisFowl Fixed, and saved some bytes
    $endgroup$
    – Embodiment of Ignorance
    19 hours ago











    2












    $begingroup$


    R, 287 bytes





    function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)')))B=eval(parse(t='^.'['','(?<=.)>$'['readLines(,1)','(@;x


    Try it online!



    Unrolled code and explanation :



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





    share|improve this answer











    $endgroup$












    • $begingroup$
      A quick -1: (@|#) can be [@#]
      $endgroup$
      – Kirill L.
      1 hour ago















    2












    $begingroup$


    R, 287 bytes





    function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)')))B=eval(parse(t='^.'['','(?<=.)>$'['readLines(,1)','(@;x


    Try it online!



    Unrolled code and explanation :



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





    share|improve this answer











    $endgroup$












    • $begingroup$
      A quick -1: (@|#) can be [@#]
      $endgroup$
      – Kirill L.
      1 hour ago













    2












    2








    2





    $begingroup$


    R, 287 bytes





    function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)')))B=eval(parse(t='^.'['','(?<=.)>$'['readLines(,1)','(@;x


    Try it online!



    Unrolled code and explanation :



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





    share|improve this answer











    $endgroup$




    R, 287 bytes





    function(C,x='',`[`=gsub,I=intToUtf8,U=utf8ToInt)')))B=eval(parse(t='^.'['','(?<=.)>$'['readLines(,1)','(@;x


    Try it online!



    Unrolled code and explanation :



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






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 1 hour ago

























    answered 2 hours ago









    digEmAlldigEmAll

    3,524515




    3,524515











    • $begingroup$
      A quick -1: (@|#) can be [@#]
      $endgroup$
      – Kirill L.
      1 hour ago
















    • $begingroup$
      A quick -1: (@|#) can be [@#]
      $endgroup$
      – Kirill L.
      1 hour ago















    $begingroup$
    A quick -1: (@|#) can be [@#]
    $endgroup$
    – Kirill L.
    1 hour ago




    $begingroup$
    A quick -1: (@|#) can be [@#]
    $endgroup$
    – Kirill L.
    1 hour ago











    1












    $begingroup$


    Ruby -palF|, 146 142 bytes





    r='';$F.map;$_=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$

















      1












      $begingroup$


      Ruby -palF|, 146 142 bytes





      r='';$F.map;$_=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$















        1












        1








        1





        $begingroup$


        Ruby -palF|, 146 142 bytes





        r='';$F.map;$_=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.map;$_=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 2 hours ago

























        answered 5 hours ago









        Kirill L.Kirill L.

        6,0081527




        6,0081527



























            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

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480