Skip to main content
added 324 characters in body
Source Link
Glen O
  • 2.9k
  • 14
  • 13

Julia, 4141 39 bytes

f(s)=foldl->foldl((t,v)->chop(t)v,split(s,"^H"))

What it's doing is using ^H as a delimiter, and then removing the last character on each string then concatenating the next string before removing the last character again. Unlike the other Julia answer, this is not a recursive function.

Note: I've removed the function name from the definition. Originally, it said f(s)= rather than s->, and you used it as f("AAA^HB^H^H")... but I'm saving two bytes by letting it be "anonymous", and use itself as its name. You use it like this:

(s->foldl((t,v)->chop(t)v,split(s,"^H")))("AAA^HB^H^H")

(you can also assign a variable to it as f=s->foldl((t,v)->chop(t)v,split(s,"^H")), then f("AAA^HB^H^H") will work)

Julia, 41 bytes

f(s)=foldl((t,v)->chop(t)v,split(s,"^H"))

What it's doing is using ^H as a delimiter, and then removing the last character on each string then concatenating the next string before removing the last character again. Unlike the other Julia answer, this is not a recursive function.

Julia, 41 39 bytes

s->foldl((t,v)->chop(t)v,split(s,"^H"))

What it's doing is using ^H as a delimiter, and then removing the last character on each string then concatenating the next string before removing the last character again. Unlike the other Julia answer, this is not a recursive function.

Note: I've removed the function name from the definition. Originally, it said f(s)= rather than s->, and you used it as f("AAA^HB^H^H")... but I'm saving two bytes by letting it be "anonymous", and use itself as its name. You use it like this:

(s->foldl((t,v)->chop(t)v,split(s,"^H")))("AAA^HB^H^H")

(you can also assign a variable to it as f=s->foldl((t,v)->chop(t)v,split(s,"^H")), then f("AAA^HB^H^H") will work)

Source Link
Glen O
  • 2.9k
  • 14
  • 13

Julia, 41 bytes

f(s)=foldl((t,v)->chop(t)v,split(s,"^H"))

What it's doing is using ^H as a delimiter, and then removing the last character on each string then concatenating the next string before removing the last character again. Unlike the other Julia answer, this is not a recursive function.