Skip to main content
added 129 characters in body
Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 5050 46 bytes

split(r<-readLinesfunction(r)split(r,substr(r,1,regexpr("\\]""]",r)))

Try it online!Try it online!

Outputs as a list with each element named with the [tag]. Each list element maintains order within its tag. Returns an empty named list named list() for empty input.

-2 bytes each thanks to Robin Ryder and Dominic van Essen!

R, 50 bytes

split(r<-readLines(),substr(r,1,regexpr("\\]",r)))

Try it online!

Outputs as a list with each element named with the [tag]. Each list element maintains order within its tag.

R, 50 46 bytes

function(r)split(r,substr(r,1,regexpr("]",r)))

Try it online!

Outputs as a list with each element named with the [tag]. Each list element maintains order within its tag. Returns an empty named list named list() for empty input.

-2 bytes each thanks to Robin Ryder and Dominic van Essen!

Source Link
Giuseppe
  • 28.8k
  • 3
  • 31
  • 105

R, 50 bytes

split(r<-readLines(),substr(r,1,regexpr("\\]",r)))

Try it online!

Outputs as a list with each element named with the [tag]. Each list element maintains order within its tag.