Skip to main content
removed the newline due to a common complaint
Source Link

Unix TMG, 49 bytes

This translation-oriented language from 1972 makes this task trivial:

p:parse(b);
b;b:<->b b={2 1<->}|<0>={<0>}|<1>={<1>};

I believe, this is the first solution in this language on this website, so I will explain a bit:

p: parse(b);                # parse() builtin: execute parsing rule `b` and output its translation
b: <-> b b = { 2 1 <-> }    # encountering "-" do recursion; translation rule is in braces
 | <0> = { <0> }            # otherwise: encountering "0" - translate as "0"
 | <1> = { <1> };           # otherwise: encountering "1" - translate as "1"

Unix TMG, 49 bytes

This translation-oriented language from 1972 makes this task trivial:

p:parse(b);
b:<->b b={2 1<->}|<0>={<0>}|<1>={<1>};

I believe, this is the first solution in this language on this website, so I will explain a bit:

p: parse(b);                # parse() builtin: execute parsing rule `b` and output its translation
b: <-> b b = { 2 1 <-> }    # encountering "-" do recursion; translation rule is in braces
 | <0> = { <0> }            # otherwise: encountering "0" - translate as "0"
 | <1> = { <1> };           # otherwise: encountering "1" - translate as "1"

Unix TMG, 49 bytes

This translation-oriented language from 1972 makes this task trivial:

p:parse(b);b:<->b b={2 1<->}|<0>={<0>}|<1>={<1>};

I believe, this is the first solution in this language on this website, so I will explain a bit:

p: parse(b);                # parse() builtin: execute parsing rule `b` and output its translation
b: <-> b b = { 2 1 <-> }    # encountering "-" do recursion; translation rule is in braces
 | <0> = { <0> }            # otherwise: encountering "0" - translate as "0"
 | <1> = { <1> };           # otherwise: encountering "1" - translate as "1"
without syntax highlighting this is actually quite confusing, so I take my words back
Source Link

Unix TMG, 49 bytes

This translation-oriented language from 1972 makes this task trivial:

p:parse(b);
b:<->b b={2 1<->}|<0>={<0>}|<1>={<1>};

I believe, this is the first solution in this language on this website. So, even though it's relatively readable, so I will explain just a bit:

p: parse(b);                # parse() builtin: execute parsing rule `b` and output its translation
b: <-> b b = { 2 1 <-> }    # encountering "-" do recursion; translation rule is in braces
 | <0> = { <0> }            # otherwise: encountering "0" - translate as "0"
 | <1> = { <1> };           # otherwise: encountering "1" - translate as "1"

Unix TMG, 49 bytes

This translation-oriented language from 1972 makes this task trivial:

p:parse(b);
b:<->b b={2 1<->}|<0>={<0>}|<1>={<1>};

I believe, this is the first solution in this language on this website. So, even though it's relatively readable, I will explain just a bit:

p: parse(b);                # parse() builtin: execute parsing rule `b` and output its translation
b: <-> b b = { 2 1 <-> }    # encountering "-" do recursion; translation rule is in braces
 | <0> = { <0> }            # otherwise: encountering "0" - translate as "0"
 | <1> = { <1> };           # otherwise: encountering "1" - translate as "1"

Unix TMG, 49 bytes

This translation-oriented language from 1972 makes this task trivial:

p:parse(b);
b:<->b b={2 1<->}|<0>={<0>}|<1>={<1>};

I believe, this is the first solution in this language on this website, so I will explain a bit:

p: parse(b);                # parse() builtin: execute parsing rule `b` and output its translation
b: <-> b b = { 2 1 <-> }    # encountering "-" do recursion; translation rule is in braces
 | <0> = { <0> }            # otherwise: encountering "0" - translate as "0"
 | <1> = { <1> };           # otherwise: encountering "1" - translate as "1"
Source Link

Unix TMG, 49 bytes

This translation-oriented language from 1972 makes this task trivial:

p:parse(b);
b:<->b b={2 1<->}|<0>={<0>}|<1>={<1>};

I believe, this is the first solution in this language on this website. So, even though it's relatively readable, I will explain just a bit:

p: parse(b);                # parse() builtin: execute parsing rule `b` and output its translation
b: <-> b b = { 2 1 <-> }    # encountering "-" do recursion; translation rule is in braces
 | <0> = { <0> }            # otherwise: encountering "0" - translate as "0"
 | <1> = { <1> };           # otherwise: encountering "1" - translate as "1"