改变路径或完善

编程入门 行业动态 更新时间:2024-10-27 07:21:59
本文介绍了改变路径或完善的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想将一个块内的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]

更多推荐

改变路径或完善

本文发布于:2023-11-23 08:59:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1620851.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!