本文介绍了改变路径或完善的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将一个块内的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,但只会更改第一部分,即a到c:
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]更多推荐
改变路径或完善
发布评论