Re: Advent of Code 2018 megathread
Here are my solutions: [https://github.com/epiphone/aoc/tree/master/2018](https://github.com/epiphone/aoc/tree/master/2018). Just started learning Nim so they're not much to look at. Enjoying the process though! Of the recent ones day 22 was particularly fun, with Dijkstra's algorithm, priority queues and whatnot. Exciting after the CRUD tedium of one's day job... Browsing other people's solutions was really helpful in picking up idiomatic Nim, so thanks for those!
Re: What pattern language does the OS module use ?
This issue is resolved. I realized that Nim uses platform-specific pattern matching for filenames. This depends on the OS in use. In this case the Windows CLI has several quirks in the way it uses wildcards (*, ? etc.) for matching filenames. These quirks seem to have been inherited from the early DOS days. This would explain why I am not getting the expected results with my above code sample. You may read more about Windows filename pattern matching at: [https://blogs.msdn.microsoft.com/jeremykuhne/2017/06/04/wildcards-in-windows](https://blogs.msdn.microsoft.com/jeremykuhne/2017/06/04/wildcards-in-windows)/
Plus equals for setter does not work
# foo.nim type Foo* = object bar: int proc `bar`*(f: var Foo): int {.inline.} = f.bar proc `bar=`*(f: var Foo, val: int) {.inline.} = f.bar = val Run # main.nim import foo var f: Foo f.bar += 1 echo f.bar Run Results in: Error: type mismatch: got but expected one of: proc `+=`[T: SomeOrdinal | uint | uint64](x: var T; y: T) for a 'var' type a variable needs to be passed, but 'bar(f)' is immutable proc `+=`[T: float | float32 | float64](x: var T; y: T) first type mismatch at position: 1 required type: var T: float or float32 or float64 but expression 'bar(f)' is of type: int for a 'var' type a variable needs to be passed, but 'bar(f)' is immutable expression: bar(f) += 1 Run
Re: Advent of Code 2018 megathread
Yeah my bad on that. Trying to be too smart too quick doesn't usually end up paying off in the end :) Thankfully, I actually got to use A* on a later problem, and I was able to copy most of the code from my first day 15 attempt, so that was a little redeeming... I don't think you are alone in taking a break; I see others doing it and almost did so myself. I can feel my sanity slowly fading as we bounce between cellular automata problems one night and assembler reverse engineering problems the next.
Re: Advent of Code 2018 megathread
I had a breadth first solution that would have worked if I would have read the specification, hmpf reading order, then I looked at your A* and that threw me of track :) Eventually I ended up width a breadth first. Your repository was of good help @nickmyers217 both help in a good and in a bad way :D Now I won't be able to solve any more before christmas, I have to revisit the remaining problems when I get home from the christmas vacation. But I can say that I have found a lovely language that I can't wait to solve stuff in.
Re: Beginner help with http client
Here is what you need to do to replicate your spawn example: # async version import httpclient, asyncdispatch, json , times let time = cpuTime() proc callStrategy (i : int) {.async.} = echo("request " & $i) let client = newAsyncHttpClient() client.headers = newHttpHeaders({ "Content-Type": "application/json" }) let body = %*{ "Pid":i } let response = await client.request("https://reqres.in/api/strategy;, httpMethod = HttpPost, body = $body) echo response.status echo await response.body echo("done " & $i) proc loop (num: int) {.async.} = echo "executing call number: " , num var futures: seq[Future[void]] = @[] for i in 1..num: echo "executing call number: " , i futures.add callStrategy(i) await all(futures) waitFor loop(10) echo "Time taken: ",cpuTime() - time Run
Re: Beginner help with http client
Thanks for the reply. Unfortunately removing the await after the echo it refuses to compile. if i keep the await and put asyncCheck it complies but does not print any response. Finally, if instead of asyncCheck i use waitFor it prints everything as expected, but does it in a synchronous way.
Re: Nim development blog
The bullet point system of talking points is excellent Having timestamps of where a point begins would also be great.