arrays - 如何将数组更改为列表
问题描述
我想创建一个函数来更改数组并在打字稿中返回节点列表。假设起始索引为 0。我在代码中遇到了几个错误。
编辑代码:
export let arrayToList = (list: [number], index: number): Node<number> => {
for (let i = list.length; i >= 0; i--) {
if (i === list.length) {
return cons(null);
} else {
return cons(list[i]);
}
}
return null;
};
解决方案
推荐阅读
- c++ - 当元素类型没有默认构造函数时如何声明 std::array?
- reactjs - 尝试自定义 Ionic Cordova VideoCapturePlus React JS 的 UI
- python-3.x - 如何将字母数字转换为数字,同时保持字符串中的实际数字不变
- flutter - flutter:: 我可以在按钮或小部件中使用条件语句吗?
- dll - 没有可用的导入库时动态链接 Windows DLL?
- reactjs - React 组件的 Prop TypeScript 错误,使用 Styled-Components
- google-chrome - Chrome 扩展 CORB 问题
- android - CardView 布局折叠动画与冻结一起使用
- image - TYPO3 10.4 / FLUIDTEMPLATE / renderObj / 图像
- apache-beam - Apache Beam 管道中的大窗口