Zipping zippers in Anti-XML

你说的曾经没有我的故事 提交于 2019-12-06 01:00:52

I can't think of a direct way to achieve what you need, but if you're willing to go for a lower level function, you can use a fold, e.g.:

val blanks = q \\ "blank"

(0 until blanks.size).foldLeft(blanks) {case (z, i) => z.updated(i, z(i).copy(
  name = "input",
  attrs = Attributes("name" -> "blank.%d".format(i + 1)))
)}.unselect

Note that the zipper is a random access container, so efficiency shouldn't be an issue in this case.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!