nimrod

    5熱度

    2回答

    我是Nim的新品牌,並且遇到了一些問題。以下代碼導致SIGSEGV: Illegal storage access. (Attempt to read from nil?)。我似乎無法弄清楚如何用值填充序列序列。 const a = @[ 0, 1, 2, 3, 4, 5] b = @[10, 11, 12, 13, 14, 15] var matrix: seq

    4熱度

    3回答

    在語言NIM,一個可以做以下的事情: let num = 5.add(3) 這將是相同的 let num = add(5,3) 所以,基本上你把之前的表達式點作爲函數的第一個參數。 我確定其他語言有這個功能,但沒有一個直接介入。 我想知道的是什麼名字這句法有

    4熱度

    1回答

    剛開始用Nim語言編寫(到目前爲止我非常喜歡)。作爲一個學習練習,我正在寫一個小型矩陣庫。我有更多的代碼,但我只會顯示與此問題相關的部分。 type Matrix*[T; nrows, ncols: static[int]] = array[0 .. (nrows * ncols - 1), T] # Get the index in the flattened array co

    5熱度

    1回答

    我在Nim(版本0.10.2)中傳遞數學函數(procs)的問題。 import math var s1 = @[1.1, 1.2, 1.3, 1.4] var s2 = map(s1, math.sqrt) 我得到的錯誤 Error: 'sqrt' cannot be passed to a procvar 如果我寫開方的包裝功能,它工作得很好。 proc fxn(x: float

    1熱度

    2回答

    我需要一個語句列表分爲多個部分,像這樣: import macros macro test: stmt = var first = quote do: var x = 1 var second = quote do: echo x result = newStmtList() first.copyChildrenTo(result

    4熱度

    2回答

    我想直接從切片中指定一個序列(而不是遍歷切片並將每個元素單獨添加到序列中)。我嘗試了幾種不同的方法,但明顯的方法似乎不起作用。 var x = newSeq(1..n) y: seq[int] = @[1..n] z: seq[int] = 1..n 我設法去工作的唯一事情是從future var x: seq[int] = lc[x | (x <- 1..n),

    5熱度

    2回答

    在Scala中,可以輕鬆地包括一個可變的字符串裏面的內容,就像這樣: val nm = "Arrr" println(s"my name is , $nm") 在NIM這是可能的,而在這種情況下,怎麼樣?

    3熱度

    1回答

    我有以下片段。第二個變量聲明沒有雖然編譯: type Coin = ref object Pen = ref object let yes : seq[ref object] = @[Coin(), Coin(), Coin()] #Compiles no : seq[ref object] = @[Coin(), Pen(), Coin()] #Doe

    2熱度

    2回答

    假設你有以下類型: type Min = 1..4 你想查一些INT裏面是否閔下降,你可以與集: 's' in {'a'..'z'} 它可能更表達出來大於: 2 in {low(Min)..high(Min)} #Too many characters 2 in Min #Expecting this conciseness

    4熱度

    2回答

    我想學習Nim及其功能,例如迭代器;我發現下面的例子工作正常。 for i in countup(1,10): # Or its equivalent 'for i in 1..10:' echo($i) 但是,下列不工作: var counter = countup(1,10) # THIS DO NOT WORK ! # counter = 1..10 # This works