Skip to main content
deleted 222 characters in body
Source Link
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

Red, 136 120120 86 bytes

func[s][a: charset"<>"until[parse s[any[change["("t: a"<"a")"](t/1)| change["("a">"t: a")"](t/1)| skip]]2 > length? s]s]

Try it online!

More readable: This version is courtesy @hiimboris (https://gitter.im/red/parse)!

f: func[s][
    a: charset "<>"
    l: [change["(" tfunc[s][r: a "<"["<"|">"]while[parse as[to ")"]change["(t/1)]
    r"x: [change["(" a ">"r["<"r t|">"x: a "r]")"](tx/1)]
    until [
        parse s[any [l | r | skip]] 
        single? s    
    ]
   to s
]end]][]s]

Try it online!

Red, 136 120 bytes

func[s][a: charset"<>"until[parse s[any[change["("t: a"<"a")"](t/1)| change["("a">"t: a")"](t/1)| skip]]2 > length? s]s]

Try it online!

More readable:

f: func[s][
    a: charset "<>"
    l: [change["(" t: a "<" a ")"](t/1)]
    r: [change["(" a ">" t: a ")"](t/1)]
    until [
        parse s[any [l | r | skip]] 
        single? s    
    ]
    s
]

Red, 136 120 86 bytes

This version is courtesy @hiimboris (https://gitter.im/red/parse)!

func[s][r:["<"|">"]while[parse s[to change["("x: r["<"r |">"x: r]")"](x/1)to end]][]s]

Try it online!

deleted 6 characters in body
Source Link
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

Red, 136 123120 bytes

func[s][a: charset"<>"until[parse s[any[[change["s[any[change["("t: a"<"a")"](t/1)]|[change["| change["("a">"t: a")"](t/1)]|| skip]]2 > length? s]s]

Try it online!Try it online!

More readable:

f: func[s][
    a: charset "<>"
    l: [change["(" t: a "<" a ")"](t/1)]
    r: [change["(" a ">" t: a ")"](t/1)]
    until [
        parse s[any [l | r | skip]] 
        single? s    
    ]
    s
]

Red, 136 123 bytes

func[s][a: charset"<>"until[parse s[any[[change["("t: a"<"a")"](t/1)]|[change["("a">"t: a")"](t/1)]| skip]]2 > length? s]s]

Try it online!

More readable:

f: func[s][
    a: charset "<>"
    l: [change["(" t: a "<" a ")"](t/1)]
    r: [change["(" a ">" t: a ")"](t/1)]
    until [
        parse s[any [l | r | skip]] 
        single? s    
    ]
    s
]

Red, 136 120 bytes

func[s][a: charset"<>"until[parse s[any[change["("t: a"<"a")"](t/1)| change["("a">"t: a")"](t/1)| skip]]2 > length? s]s]

Try it online!

More readable:

f: func[s][
    a: charset "<>"
    l: [change["(" t: a "<" a ")"](t/1)]
    r: [change["(" a ">" t: a ")"](t/1)]
    until [
        parse s[any [l | r | skip]] 
        single? s    
    ]
    s
]
deleted 77 characters in body
Source Link
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61

Red, 136136 123 bytes

func[s][a: charset"<>"until[parse s[any[[change[t: a"<"a]s[any[[change["(t/1)]|[change[a">"t"t: a]a"<"a")"](t/1)]| change["]|[change["("t"a">"t: a")"](t/1)|]| skip]]2 > length? s]s]

Try it online!Try it online!

More readable:

f: func[s][
    a: charset "<>"
    l: [change[t[change["(" t: a "<" a]a ")"](t/1)]
    r: [change[a[change["(" a ">" t: a]a ")"](t/1)]
    until [
        parse s[
            any [
                s[any l[l | r 
               | change ["(" t: a ")"](t/1)
               | skip
           skip]] ]
        ]   
       single? s    
    ]
    s
]

Red, 136 bytes

func[s][a: charset"<>"until[parse s[any[[change[t: a"<"a](t/1)]|[change[a">"t: a](t/1)]| change["("t: a")"](t/1)| skip]]2 > length? s]s]

Try it online!

More readable:

f: func[s][
    a: charset "<>"
    l: [change[t: a "<" a](t/1)]
    r: [change[a ">" t: a](t/1)]
    until [
        parse s[
            any [
                 l | r 
               | change ["(" t: a ")"](t/1)
               | skip
            ]
        ]   
       single? s    
    ]
    s
]

Red, 136 123 bytes

func[s][a: charset"<>"until[parse s[any[[change["("t: a"<"a")"](t/1)]|[change["("a">"t: a")"](t/1)]| skip]]2 > length? s]s]

Try it online!

More readable:

f: func[s][
    a: charset "<>"
    l: [change["(" t: a "<" a ")"](t/1)]
    r: [change["(" a ">" t: a ")"](t/1)]
    until [
        parse s[any [l | r | skip]] 
        single? s    
    ]
    s
]
Source Link
Galen Ivanov
  • 21.2k
  • 3
  • 24
  • 61
Loading