nim-lang Questions

5

Solved

I am expecting the code below to print chr7. import strutils var splitLine = "chr7 127471196 127472363 Pos1 0 +".split() var chrom, startPos, endPos = splitLine[0..2] echo chrom Instead it prin...
Eddra asked 11/8, 2015 at 17:22

2

Solved

var b: array[5, int] type ArrRef = ref array[5, int] var c : ArrRef echo repr(c) # nil c = addr b # doesn't compile, says type is Array constructor, expected reference In Nim, how can I pass r...
Dost asked 1/6, 2015 at 22:8

2

Solved

During quick and dirty debugging, I often use expressions like: echo "variable1: ", variable1, " variable2: ", variable2 How can I leverage Nim's macro system to avoid repeating the variable nam...
Idyllist asked 22/11, 2017 at 20:14

2

Solved

I have a sequence generated by list comprehension as follows: var a_bigram_list = lc[a[i..i+2] | (i <- 0..<len(a)), string] Now, I would like to sort it but sort(a_bigram_list) will result...
Spontaneity asked 1/3, 2017 at 11:11

2

Solved

Let's say I have the following sequences: var s1: seq[int] = @[] var s2: seq[int] var s3: seq[int] = nil var s4: seq[int] = newSeq[int](4) Which of these are typically considered "empty"? And wh...
Gans asked 7/2, 2018 at 6:22

4

Solved

How can I access command line arguments in Nim? The documentation shows only how to run the compiled Nim code with command line arguments nim compile --run greetings.nim arg1 arg2 but I didn'...
Nabila asked 12/4, 2017 at 11:29

2

Solved

Nim turns its own code into C code and compiles that using C-compilers. Zig has its own compiler that has many nice features that would make you want to use it, such as allowing you to choose which...
Therewith asked 13/8, 2022 at 15:44

7

Solved

I want to do different operations with the characters in a string e.g. map or reverse. As a first step I want to convert the string into a sequence. Given a string like "ab". How do I get a seque...
Sitting asked 14/6, 2018 at 8:51

2

Solved

I would like to print without skipping lines in Nim. this is my code by far int i = 1 for i in countup(1, 10): echo "number: " echo i I would like the output to be: number: (i value) ....
Miller asked 9/8, 2020 at 11:12

1

Solved

How to replace some string with Nim ? var pythonista:string = "Power of Python!" echo pythonista
Phenomenal asked 14/12, 2021 at 20:46

2

Solved

When working on compile time features it would be nice to echo something at compile time. If an echo is withing a macro it is already executed at compile time. But is it also possible to print some...
Joppa asked 19/2, 2017 at 12:28

4

Solved

Since Nim shares a lot of features with Python, i would not be surprised if it implements Python's list comprehension too: string = "Hello 12345 World" numbers = [x for x in string if x.isdigit()]...
Endocardium asked 27/4, 2015 at 12:33

3

Solved

Following is the content of foo.py import sys print(sys.executable) When I execute this, I can get the full path of the the Python interpreter that called this script. $ /mingw64/bin/python3.9.exe...
Frerichs asked 22/10, 2021 at 10:18

2

Solved

I would like to know if it is possible to get the type (int32 / float64 / string) from a value in Nim at runtime? I thought this would be possible with the "typeinfo" library but I can't figure it...
Udder asked 5/2, 2015 at 19:36

3

Solved

In scala, you easily include the content of a variable inside a string, like this: val nm = "Arrr" println(s"my name is , $nm") Is this possible in nim, and in that case, how?
Linalinacre asked 17/4, 2015 at 16:39

2

Solved

I know there is echo, which writes to stdout. Is it possible to redirect echo to stderr, or is there another way to write to stderr?
Protist asked 23/10, 2017 at 20:27

2

Solved

I'm trying to perform the equivalent of the eval method from Python in nim. I was under the impression that parseStmt from the macros package should help me with this, but I'm facing a compilation ...
Guilbert asked 18/12, 2020 at 8:55

2

Solved

I wrote a Nim procedure taking two objects as var parameters. They each are an object with an int field level. Before doing the real work of the procedure, I want to put the parameters in order by ...
Rickart asked 8/10, 2020 at 1:23

1

One thing I like in Go and can't seem to find in Nim yet is Go-like, "modified CSP" kind of parallelism. I have not even started learning Nim yet, just considering my options for now. I quite like...
Berns asked 21/1, 2020 at 14:45

1

Solved

I need to save a cache to disk periodically, every 500ms, how can I do that? The code I tried is not compiled properly. Also, it seems that the asyncCheck should be used for error checking. import ...
Rathskeller asked 7/9, 2020 at 4:23

1

Solved

I've created a nimble library package as per the documentation. When I try to build it using nimble build I get the following error. Error: Nothing to build. Did you specify a module to build usin...
Alegar asked 1/9, 2020 at 17:45

4

Solved

I'm making a small web service in Nim, and I need to respond to requests with json. I'm using the jester module to make the service. I expect I can use the json module in Nim's base library to cons...
Bindle asked 4/10, 2014 at 8:36

1

Solved

Following the docs here: https://nim-lang.org/docs/backends.html#backends-the-javascript-target I have the following code in fib.nim proc fib(a: cint): cint {.exportc.} = if a <= 2: result = 1...
Meritorious asked 3/7, 2020 at 4:40

2

Solved

Nim backend integration guide describes how to call a Nim function from C. Example function: proc fib(a: cint): cint {.exportc.} = if a <= 2: result = 1 else: result = fib(a - 1) + fib(a -...
Statistical asked 23/1, 2020 at 13:26

2

Solved

What is the modulus operator in Nim? tile % 9 == 0 results in undeclared identifier: '%' Googling or searching SO doesn't bring up an answer.
Mongo asked 25/9, 2018 at 6:14

© 2022 - 2024 — McMap. All rights reserved.