小编Art*_*ras的帖子

尼姆范围超出范围

所以我是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)

arrays nim-lang

1
推荐指数
1
解决办法
178
查看次数

为什么不能在Go中将变量作为多维数组大小?

最近,我一直对机器学习更感兴趣,机器学习图像,但要做到这一点,我需要能够处理图像.我想更全面地了解图像处理库如何工作,所以我决定创建自己的库来阅读我能理解的图像.但是,在读取图像的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)

arrays image-processing go computer-vision

0
推荐指数
1
解决办法
207
查看次数

标签 统计

arrays ×2

computer-vision ×1

go ×1

image-processing ×1

nim-lang ×1