所以我是Nim的新手.对不起,如果这听起来很棒.这是我的代码:
proc makeMap(width: int, size: int): seq[int]=
var theMap = newSeq[int](size)
var playerPos: int = 249750
var i: int = 0;
for i in 1..size:
if i<width:
theMap[i] = 2
elif i == playerPos:
theMap[i] = 1
else:
theMap[i] = 0
return theMap
var width = 500;
var height = 500;
var nsize: int = width * height
var myMap = makeMap(width, nsize)
echo "Map: ", myMap
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
nim.nim(18) nim
nim.nim(8) makeMap
system.nim(2833) sysFatal
Error: unhandled exception: index out of …Run Code Online (Sandbox Code Playgroud) 最近,我一直对机器学习更感兴趣,机器学习图像,但要做到这一点,我需要能够处理图像.我想更全面地了解图像处理库如何工作,所以我决定创建自己的库来阅读我能理解的图像.但是,在读取图像的SIZE时,我似乎遇到了一个问题,因为当我尝试编译时会弹出这个错误:
./imageProcessing.go:33:11: non-constant array bound Size
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
package main
import (
// "fmt"
// "os"
)
// This function reads a dimension of an image you would use it like readImageDimension("IMAGENAME.PNG", "HEIGHT")
func readImageDimension(path string, which string) int{
var dimensionyes int
if(which == "" || which == " "){
panic ("You have not entered which dimension you want to have.")
} else if (which == "Height" || which == "HEIGHT" || which == "height" || which == "h" …Run Code Online (Sandbox Code Playgroud)