Re: split does not seem to work properly
> As you can guess, my idea is to parse a comma separated value file, or csv > file for short. (...) I don't have any experience with Python at all. I have a lot of experience with Python and this is sincere advise without being snarky: don't try to write your own manual csv parser, use `csv` module: [https://docs.python.org/3/library/csv.html](https://docs.python.org/3/library/csv.html) (I've learnt that the hard way. Never again.) > Probably, if I knew Python, I would be able to devise a good solution for Nim. Translating Python solution I advise above to Nim, you should use `parsecsv` module: [https://nim-lang.github.io/Nim/parsecsv.html](https://nim-lang.github.io/Nim/parsecsv.html)
Re: Hacktoberfest with Nim
BUMP! Half of October is behind us, two more weeks to make your PRs to win a T-shirt.
Re: Rewrite daemonic CMS to NIM?
You may want to take a look at [Litestore](https://github.com/h3rald/litestore) which is a lightweight CMS-like server written in Nim.
Re: Rewrite daemonic CMS to NIM?
1\. PHP is a horrible language by every measure. 2\. Scripting languages [scale very poorly](https://www.techempower.com/benchmarks/#section=data-r17=cl=json) on the server end. 3\. The name of the programming language is "Nim", not "NIM", which implies it's an initialism. (* Calling it < **N** >ew < **I** >mproved < **M** >odula-3 was a joke. *) 4\. Regular JS (as generated by Nim's JS backend) still has some advantages compared to WebAssembly...
Re: Nim for enterprise software development
> Delphi has now the ability to run its code and GUI's on multiple platforms. > In a study Delphi had 70% of the speed of Microsoft visual c++ compiler. But > Delphi's compiler is lightning fast, it is almost like python in that sense. > Delphi also has an amazing RAD development package and is easy to learn and > use. Nim is far ahead of Delphi in portability, syntax efficiency, and license freedom. I don't see Delphi in any popular benchmarks. I'd like to see specific numbers on compile time, static executable size, CPU performance, [server scalability](https://www.techempower.com/benchmarks/#section=data-r17=cl=json), etc. Qt Studio with closer Nim integration would be a lot better RAD than Delphi...
Re: Anyone here used Nim with JUCE?
Someone is yet to write a JUCE library for Nim. Out of curiosity, what made you choose JUCE over [the alternatives](https://en.wikipedia.org/wiki/List_of_widget_toolkits)? JUCE has a big down-side of being [GPLv3/commercial licensed](https://github.com/WeAreROLI/JUCE/blob/master/LICENSE.md), and thus not very popular. The two most popular portable GUI choices, Qt and GTK both use **L** -GPL. But I think Nim can do even better by focusing on something new and genuinely free... Related: * [Making a Cross-Platform App in $currentYear](https://blog.budgetwithbuckets.com/2018/12/13/making-an-app-2018.html) * [Cross-Platform GUI Toolkit Trainwreck](https://blog.johnnovak.net/2016/05/29/cross-platform-gui-trainwreck-2016-edition/)
Re: I think we can really do better...
[Kostya's benchmarks](https://github.com/kostya/benchmarks) have become updated again [after a long absence](https://github.com/kostya/benchmarks/issues/179), featuring Nim v1.0.0, Rust stable, the current versions of the D compiler trio, etc. Nim's BF2 results have improved compared to [the past](https://archive.fo/8WJUb#selection-2157.0-2160.0): both Nim backends now beat Rust, and Nim-Clang now beats LDC. There's still room for improvement in other tests. There's a new maintainer. Hope the Nim community will submit improved implementations.
R-Tree module -- what can we improve?
I have just shipped version 0.2 of Nim R-Tree module rtree.nim to github. Integration in nimble data base should occur soon. [https://github.com/StefanSalewski/RTree](https://github.com/StefanSalewski/RTree) This is a fully generic module with insert(), delete(), search(), bulk-load() and nearest-neighbor search support. I am not fully satisfied with the code, maybe we can improve it?
Re: split does not seem to work properly
There is also the `parsecsv` stdlib module just for that...
Re: split does not seem to work properly
I honestly don't see an issue with your solution that uses a filter. That's how it would be done in any other language. If you don't want the extra proc definition, you can use the `=>` sugar like you did with map: import os, strutils, sequtils, sugar proc main() = if paramCount() < 1: quit("Usage: x-sexpr.x 1000") let s = readFile(paramStr(1)).split(Whitespace+{','}) xs= s.filter(x => x.len > 0).map(x => parseFloat x) echo "Average= ", xs.foldl(a + b)/float(xs.len) main() Run
Re: query pc specification?
Its not much but is std lib, `hostCPU`, `countProcessors`, `cpuEndian`, `hostOS`, `getHostname`, `getTotalMem`.
Re: split does not seem to work properly
Dear miran. I tried your suggestion, and I keep having problems. As you can guess, my idea is to parse a comma separated value file, or _csv file_ for short. In practice, csv files are not separated only by commas. You will find people that combine commas with spaces, or use only spaces. On the contrary of what araq says, I never had problems of writing efficient two line programs for such a task in a straightforward way. As previously mentioned, splitWhitespace works. Then I was able to write something inefficient and messy, such as: import os, strutils, sequtils, sugar proc main() = if paramCount() < 1: quit("Usage: x-sexpr.x 1000") let s = readFile(paramStr(1)).strip.split(Whitespace+{','}) ns = s.join(" ") xs= ns.splitWhitespace.map(x => x.parseFloat) echo "Average= ", xs.foldl(a+b)/float(xs.len) main() Another possibility is this: import os, strutils, sequtils, sugar proc fil(x:string) : bool = x != "" proc main() = if paramCount() < 1: quit("Usage: x-sexpr.x 1000") let s= readFile(paramStr(1)).strip.split(Whitespace+{','}) xs= s.filter(fil).map(x => x.parseFloat) echo "Average= ", xs.foldl(a+b)/float(xs.len) main() I can also add a new iterator/procedure to the strutils.nim library: iterator splitit*(s: string, seps: set[char]= Whitespace, m: int = -1): string = oldSplit(s, seps, m) proc splitit*(s: string, seps: set[char]= Whitespace, m: int = -1): seq[string] {.noSideEffect, rtl.}= accResult(splitit(s, seps, m)) Although they work, all these solutions are convoluted. Well, splitit* is not convoluted, but I can hardly share it with my collaborators, since it is not in the strutils library by default. Here are short examples of files that I would like to parse: eg> cat csv.data 190, 180, 170, 160, 120, 100,100, 90 eg> cat nums.data 190 45 23 34 89 96 78 97 14 17 54 345 3 42 eg> cat grad.data 190 180 170 160 120 100 100 90 Of course, I started learning Nim three days ago, and I don't have any experience with Python at all. Probably, if I knew Python, I would be able to devise a good solution for Nim. However, my experience is with Common Lisp, where the _clawk library_ allows me to write very efficient Data Munging programs. To make a long story short, could you suggest a concise and efficient solution in Nim?
Re: query pc specification?
I'm right in the middle of adding Windows support to psutil for Hacktoberfest, but I don't have any exemplar code for things like identifying the graphics card or CPU type (the python version psutil doesn't do either of those). If you have exemplar Win32 C code or can figure out what to pass to the function @Araq found I'd be happy to add it. PRs always welcome as well ;)
Re: query pc specification?
psutil
Re: query pc specification?
I don't know, I found this in my search: [https://docs.microsoft.com/de-de/windows/win32/api/setupapi/nf-setupapi-setupdigetclassdevsexa](https://docs.microsoft.com/de-de/windows/win32/api/setupapi/nf-setupapi-setupdigetclassdevsexa) Wrapping this via c2nim or manually isn't hard.
Re: Using NIM for sending emails through Outlook app
Well, thanks. I managed to write this code and it works: import winim/com var obj = CreateObject("Outlook.Application") var olMailItem = 0x0 var newMail = obj.CreateItem(olMailItem) newMail.Subject = "test" newMail.Body = "Bodytest" newMail.display() Run I'll leave it here as somebody might need it in the future.
Re: query pc specification?
lscpu, lspci, lshw, lsblk, ... rest of ls family or use dmidecode and pass the output to nim-dmidecode [https://github.com/xmonader/nim-dmidecode](https://github.com/xmonader/nim-dmidecode)
Re: Manu v1.1 - Matrix Numeric package released!
Docs are up [https://b3liever.github.io/manu/index.html](https://b3liever.github.io/manu/index.html)
query pc specification?
is there any way or package to query pc specification on Ms Windows is? to be clear, foe example I need to know: CPU type(for example Intel Core i7-8700 @ 3.2Ghz), display card(e.g. Nvidia geforce 1080), 2 hardisk(st31000528as 1T, kbg30xxx Toshiba 256G), memeory(16G), just like what cpu-z does. additional, is it possible to know which monitor/displayer is used? author additional question, is it possible to get all PCs specification under the same LAN? btw, I have searched that Windows Management Instrumentation (Ami maybe useful) but I did not find a smile package for nim yet. thanks
Re: split does not seem to work properly
Well yes, that's how it was designed and iirc it's consistent with how Python and others do it.
Re: split does not seem to work properly
Change `s = readFile(paramStr(1)).split(Whitespace)` to `s = readFile(paramStr(1)).strip.split(Whitespace)`