Hi, I am new in this forum and as a Nim user.
I'll post my solutions here:
[https://github.com/JulienRobitaille/AoC2018](https://github.com/JulienRobitaille/AoC2018)
I use this year advent of code as an opportunity to learn Nim :)
If you use devel, this is now straightforward.
[https://nim-lang.github.io/Nim/nimc.html#cross-compilation-for-windows](https://nim-lang.github.io/Nim/nimc.html#cross-compilation-for-windows)
echo len"a" + 1 # Ok, parses as len("a") + 1
echo ord'a' + 1 # Error, parses as ord('a' + 1)
Run
I think the second line must be parsed as the first one
This has worked for me: $ sudo apt-get install mingw-w64 $ nim --os:windows
--cpu:amd64 --gcc.exe:x86_64-w64-mingw32-gcc
--gcc.linkerexe:x86_64-w64-mingw32-gcc c src/uitest.nim
I recently picked up Nim In Action and have been reading through it, so here's
a perfect way to get some practice in. I'm in PST so my place on the private
leaderboard is pretty abysmal so far.
repo:
The getAddrInfo call doesn't return the full struct (only to 0xfff1). Moreover
the first couple of bytes are _not_ part of the IPv6 address and the first
address byte is the 5th byte after 0x50 (0x20, 0x1, ...).
Frankly, I don't think it worth putting more work into the current solution. If
I am confused by lots of things, including that the same constants like
AF_INET6 are present with different values in `lib/nativesockets.nim` vs
`lib/posix/posix_linux_amd64_consts.nim`.
The edited above code now uses posix's AF_INET6 value (10.cint) cast to
nativesockets Domain enum for
Hi All, I'm writing a small app, and using the JSON module I have a section of
code like this:
var json_response = parseJson(response.body)
echo $json_response["settings"]{"pollingRate"}[].kind
Run
Which works. But, this doesn't:
var json_response
Thanks for the clarification.
sequtils.toSeq(...)
Run
should work even with `nre`, or do `import nre except toSeq`
https://github.com/nim-lang/Nim/pull/9846
You are right and I'm a fool for not providing the whole code. In my original
code I imported `nre` and the following can be seen in the documentation for
that library:
: If you love sequtils.toSeq we have bad news for you. This library doesn't
work with it due to documented
I'm far from a Nim expert, but I think GC safety is determined by access of
global variables. Does this section of the manual reference anything useful?
[https://nim-lang.org/docs/manual.html#threads-gc-safety](https://nim-lang.org/docs/manual.html#threads-gc-safety)
This file compiles and executes as expected for me:
import tables, sequtils
var counter = initCountTable[char]()
echo toSeq(counter.values)
Run
Not sure why it isn't working for you. What version of the Nim compiler are you
using?
This works:
var counter = initCountTable[char]()
for v in counter.values:
echo v
Run
Documentationation says `toSeq()` "transforms any iterator into a sequence" so
I would except this to work:
var counter = initCountTable[char]()
echo
Did day 3.
Things I've missed in nim:
"difference" for OrderedSet, or a method to convert back to a HashSet so I can
apply difference. Ended up just declaring the set as HashSet; OrderedSet was
useful to visualize, but not necessary.
Better tutorial for regular expressions. Ended up with
Hello, I'm new to Nim and I'm learning it by making some little apps, reading
_Nim in Action_ and so on. During my exploration I found that with higher
verbosity level the compiler complains my code on GC-safety with a warning like
`Warning: not GC-safe: 'foo()' [GcUnsafe]`. I've tried to look
Runtime and compile time are programming terms that refer to different stages
of software program development. Compile-time is the instance where the code
you entered is converted to executable while run-time is the instance where the
executable is running. The terms "runtime" and "compile
Unfortunately this is the doc generator that works like this.
But you can raise a feature request to give more visibility:
[https://github.com/nim-lang/Nim/issues](https://github.com/nim-lang/Nim/issues)
(or change the title of this thread so that people can see the new subject at
a glance).
You're almost spot on.
The limitation is that the types must be known at compile-time. The value can
be set at runtime.
Great if that works for you! In any case, the constraint on types comes from
the fact that the only way to construct an HCons is with the cons function
(because the h and t fields are private) and the only two exported overloads
only allow valid constructions
Thanks for the table-clear hint... i swear i'll finish my Advent of Code
someday...
> Global example code can be done before the type definitions Procs and methods
> are already below there type definitions
In
I'm trying to figure out how to handle error if there are issues with directory
permission and user is not able to walk into. as per os.walkDir I think it
should raise OSError exception
iterator walkDir(dir: string; relative = false): tuple[kind: PathComponent,
path: string]
23 matches
Mail list logo