改变路径或完善 [英] Change path or refinement

查看:97
本文介绍了改变路径或完善的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个块内的a/b更改为a/c(甚至可能是a)

I want to change the a/b inside a block to a/c (or possibly even a)

我通常这样做的方法是使用change:

The normal way I'd do this is with change:

test: [a/b]
change test/1 'c

,但只会更改第一部分,即ac:

but it only changes the first part, i.e. a to c:

>> test
== [c/b]

也无法使用test/2访问路径:

>> reduce [test/1 test/2]
== [a/b none]

推荐答案

这里有两点需要注意:

首先,path!是一个序列,因此在这种情况下是嵌套序列.必须实际访问 second 元素内部 first 元素:

First, path! is a series, so in this case, a nested series. Have to actually access the second element inside the first element:

>> test: [a/b] test/1/2
== b

第二,使用series的属性,使它们的行为类似于指针并访问next元素,而不是直接访问

Secondly, use the property of series that make them behave like pointers and access the next element, instead of accessing it directly:

>> next test/1
== b

因此代码变为:

>> change next test/1 'c test
== [a/c]

这篇关于改变路径或完善的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆