> procedure to wait for the user answer to close the window
You can use `readLine` at the end of your program. See some examples in
[tut1](https://nim-lang.github.io/Nim/tut1.html#the-first-program) and [Nim
Basics](https://narimiran.github.io/nim-basics/#_reading_user_input).
> the book expects you to have some other language knowledge first
[Nim basics tutorial](https://narimiran.github.io/nim-basics/) doesn't expect
you to have some prior knowledge, and shows you the basic concepts in Nim.
> If you type `go doc fmt Println` in terminal you can get a small peace of
> information (...) right there in terminal.
[This nim plugin for Neovim](https://github.com/alaviss/nim.nvim) gives you
even better functionality, IMO. You don't have to type any special command in
terminal, as you typ
> written by hand?
Yes.
Those two packages are now at:
* [https://github.com/narimiran/blake2](https://github.com/narimiran/blake2)
* [https://github.com/narimiran/sha3](https://github.com/narimiran/sha3)
Nimble's `packages.json` has been updated with the new locations, so the
installing them should be the same a
> Maybe someone wants take care?
If nobody else replies by the end of the day or so, I can take them.
> What's the reasoning behind this again?
Before we used to have one devel and one stable. So devel was always
`stable+0.0.1`. That worked fine.
But we switched to this "backport mode" where minor version numbers (e.g.
0.20.2, 0.20.4, etc.) have only bugfixes compared to their major release (e.
> Note that since only bug fixes made it to 0.20.2 there are a lot of commits
> done in 0.20.1 that will only be merged in 0.21.0
Minor nitpick: 0.20.1 was indeed a version between 0.20.0 and 0.20.2, but the
devel version (one between 0.20.x and 0.21/1.1) has 0.20.99 version number.
After a month of hard work, our second release candidate of Nim 1.0 is ready —
Nim v0.20.2:
[https://nim-lang.org/blog/2019/07/17/version-0202-released.html](https://nim-lang.org/blog/2019/07/17/version-0202-released.html)
> I think it would be good to have a more fleshed out "Nim for {programming
> language} programmers". There are some of them on the github page
>
> I would happily contribute to something line that
*
[https://github.com/nim-lang/Nim/wiki/Nim-for-C-programmers](https://github.com/nim-lang/Nim/
There is
[countup](https://nim-lang.github.io/Nim/system.html#countup.i%2CT%2CT%2CPositive),
which can be used as:
var text = "Hello there How are you This is a string Blah Blah Blah"
for i in countup(0, len(text)-3, 2):
echo text[i],text[i+1],text[i+2]
Run
@Araq:
> Any chance we can get this covered by "important_packages"?
@Ward:
> Excuse me, I don't know how to do or what to do.
@mratsim:
> You don't have much to do.
...because I'll do it for you ;)
I've pushed it to my branch and now we just need to wait and see if Appveyor
can successfull
> What prevents it from being used only like this without "%", "@" or "toTable"?
Just a two comments above:
> `{}` is a sugar for array of tuples
.
Sponsors and donations page has been updated.
`devel` is the main (trunk) branch. All the development (and pull requests)
happens against that branch, and it is "cutting edge" \-- Nim built from it has
version `0.20.99`.
`version-0-20` branch contains backported (cherry-picked) bugfixes from devel.
Currently it is at version `0.20.1`, whic
"≈1.2 million lines of code per second per CPU core"
(I heard it is now very popular to post claims about programming language
without any proof and backing :P :D)
P.S. If anybody tries to disapprove these numbers, I'll just edit the post and
add "WIP" there. Problem solved.
* * *
(Hopefully,
`entry` is a tuple, use `fields` iterator for iterating over it. Something like
this:
for entry in data:
var rating = 0.0
for x in entry.fields:
if typeof(x) is float:
rating += getRating(i, x)
Run
> Any thoughts?
This is a bug. I'll fix it.
> let's say all I care for is that the input parameter can be iterated over.
If I'm understanding you correctly, you want to iterate over your "list"? If so:
iterator myIterator(a: openArray[int]): int =
for x in a:
yield 10*x
let l = @[1, 2, 3]
for n
> You can iterate over an openarray, of course. But not on a tuple, as fields
> may have different types.
let a = (1, "two", @[3, 4])
for x in fields(a):
echo x
Run
> Last updated: 2018-08-09
^
> btw, is there any builtin type which is true positive integer
Yes, to be technically correct `Natural` is non-negative (from zero and above),
and `Positive` is strictly positive (from one above).
[https://nim-lang.github.io/Nim/system.html#Natural](https://nim-lang.github.io/Nim/system.html#Na
> I get the following error when trying to compile my code.
Show us your code.
> Nim 0.20.0 is now in Debian Unstable and will trickle down to Ubuntu and
> other derivatives.
Also, Nim 0.20.0 is now in Manjaro Testing, and it will probably be in the next
Manjaro Stable updade.
> does -d:danger do the same that previously release did?
Yes.
> `const x = uint32(-1)` was really useful, shall we rely now on
> `cast[uint32](-1)` ?
`const x = uint32(not 0)`
> What's the reason behind this decision?
Explicit is better than implicit. See [this
issue](https://github.com/nim
> Error: cannot open file: X"
The fix has just been pushed
([link](https://github.com/nim-lang/opengl/commit/f988766539523f79d2b49ecc238d12724142b910)).
See if nimble install opengl@#head solves it for you.
> There is a way using strutils or regex package to split on whitespace but
> ignoring space in quoted arguments ?
You could use:
[https://nim-lang.github.io/Nim/parseopt.html](https://nim-lang.github.io/Nim/parseopt.html)
>From `streams.nim`:
when not defined(js):
type
StringStream* = ref StringStreamObj
## A stream that encapsulates a string.
##
## **Note:** Not available for JS backend.
# (...)
proc newStringStream*(s: string =
I confirm that hints are printed on Nim devel (0.19.9), but they are **not**
printed on stable version (I tried 0.19.6 and 0.19.4).
And for the first time, Nim is now Manjaro package and v0.19.6 has just hit
Manjaro Stable.
(Until two days ago it was dependent on Archlinux Nim package, which is still
at version 0.18.0, regardless of outdated flag and repeated mails to the
maintainer)
> Any recommendations for other plugins that are useful?
Look at plugins by [tpope](https://github.com/tpope/), lots of (must-have)
goodies there.
Other stuff you'll pick along the way based on your preferences, but here are
some of mine: fzf.vim, vim-gitgutter, rainbow, supertab, vim-highlight
@akavel, from your comment on lobste.rs:
> this may be solved if there’s some IDE support (i.e. “go to definition”)
> available; I haven’t searched for it yet.
I've successfully used go to definition, both in VSCode and Neovim (with
[nim.nvim plugin](https://github.com/alaviss/nim.nvim)).
> Th
Almost 8 months after the release of v0.19.0, here is the third bugfix release:
[https://nim-lang.org/blog/2019/05/13/version-0196-released.html](https://nim-lang.org/blog/2019/05/13/version-0196-released.html)
If you use choosenim, the new version is just `choosenim update stable` away,
otherwi
> Here's the un-optimized Nim code.
Can you show us the optimized Nim code too, so that we can see if we can
reproduce this large discrepancy?
> What am I doing wrong?
You're not using `ref object`:
type
A = ref object of RootObj
name: string
B = ref object of A
value: string
C = ref object of A
key: int
Run
Since your original question is already answered, here is one neat trick you
can use:
const letters = toSeq('a'..'z').toSet()
Run
> Tuples are defined like an object, but with square brackets on the same line
You can define them exactly the same as the objects (so there you go, another
example for your "more than should be necessary" syntax list :))
type
Person = tuple
name: string
age: i
> So can one beat the c version?
Long time ago I concluded that when it comes to optimizations, I can optimize
all day and night, but then at some point @mratsim will come and will improve
it by 50+% :D
So if you want to beat C, basically wait for @mratsim to show up and do his
magic :)
> I can't found a normal sleep function.
What is abnormal about the one you found?
> Does anyone know whether `{.noInit.}` applies to `newSeq()`?
You could use
[newSeqUninitialized](https://nim-lang.github.io/Nim/system.html#newSeqUninitialized%2CNatural).
> And Nim may not be the best starting point for someone without any computer
> experience.
Maybe not _the best_ , but I still think you can start with Nim: [shameless
self-plug](https://narimiran.github.io/nim-basics/) (and it is available as
PDF!).
> Is there are something like this in Nim?
proc foo =
discard
Run
> @mratsim is probably intending to refer to the .. including 50 in Nim while
> the C for with a < excludes 50
I doubt that because he has written **1** .. 50 ;)
Use this:
array[MSA_BASE_GROUP_LEN, align_tag_col_t]
Run
> is there something similar to std::map in Nim?
>
> (from the link): std::map is an associative container that store elements in
> key-value pair.
[https://nim-lang.github.io/Nim/tables.html](https://nim-lang.github.io/Nim/tables.html)
?
> This plugin works great and I get excited when I see new commits.
I can confirm this, and I'll add that @leorize was very helpful when I had some
initial problems in setting this up (due to my inexperience with neovim, not
plugin's fault).
I'm very impressed with how this plugin works, and th
> two separate files namely nim.sh and nimble.sh
No, you can have it in one file — I've edited my message above to show this.
> added path to .bachrc. Works fine, But no code completion now in vs code.
I think I had a similar problem with `.bashrc` and VS Code, which I solved by
removing that from `.bashrc` and adding a new file `nim.sh` to `/etc/profile.d`
with this content:
PATH=/home/miran/.nimble/
And since @ryukoposting didn't do it himself, I must do it for him :)
Here is his first video:
[http://ryuk.ooo/videos.html](http://ryuk.ooo/videos.html) \- very nice
presentation and explanations, I'm looking forward to the next ones!
> This is a big issue that I've been thinking about. I have an okay-ish
> tabletop mic,
One think you could/should do is put a towel underneath your mic-stand. It
reduces vibrations, killing some loud unpleasant keyboard sounds.
> It's great, is it possible add link to the official tutorial?
It is already here:
[https://nim-lang.org/learn.html](https://nim-lang.org/learn.html)
> I will be using Kate for the videos
Here's one (ok, two) small technical advice:
* people don't watch the videos in full screen mode — make sure you use large
font size so the content is easily viewable at the usual online-video size
* please make sure that your keyboard is not louder than
> ... but if you can, you should avoid using `int` for `bool`
... as it was—I thougth—clearly stated in the linked example: `# bad style
ahead: Nim is not C.` as well in my post ("if you _really_ want").
> `if(not gladLoadGL()):`
>
> `type mismatch: got <>`
How does your `gladLoadGL` proc look like?
> of course, nim doesn't implicitly converts ints to booleans.
... but if you really want, you can use
[converters](https://nim-lang.github.io/Nim/manual.html#converters).
> sorry, I solved the problem
For the sake of somebody else who will have a similar problem in the future,
don't just say that, also write how did you solve it.
> `for i in 0..a.size:`
Just a basic remark, and others, who are more experienced with C++, can help
you with the rest: `..` is inclusive range, here you need to use `..<`.
> I created myself some future problems by writing `include objects`
FTFY
One more week, one more quick recap.
In addition to 10 already improved modules last week, we now have better
documentation for **7 more** modules:
* sets, insets, parseopt, xmltree, algorithm, parsecsv, os
Also, now when you're viewing the documentation for some proc, you can click on
its
> Numpy in Python has an important place for computing tasks and until we have
> an equivalent (or better) package in nim, we may need to delegate some work
> to NumPy (or vice versa).
I'm not saying it is an equivalent to numpy, but I had a good experience with
using [Neo](https://github.com/u
> I do hope someone, who knows nimlang well, can join or give suggestions
Here's a suggestion: don't use upper first letter for proc and variable names :P
> I have the feeling that finding find is hard for beginners, as it is hidden
> in system. How can we improve that?
I currently don't have the answer, but maybe @dom96's
[proposal](https://github.com/nim-lang/Nim/issues/10385) would be the way to go?
`import sequtils var a = @[1, 2, 3] a.delete(a.find(3)) `
Run
And now for a slightly longer answer:
> 1\. It is not the number of digits after the decimal point, it is the number
> of digits. You made the sentence longer, which restrict it truth value to
> output in scientific notation.
I didn't change anything there except put the capital letter in the b
PRs welcome ;)
A quick recap what has been done in the last week.
Nim now has improved documentation for the following **10** modules, and you
can view their documentation on [this
link](https://nim-lang.github.io/Nim/lib.html):
* strutils, sequtils, tables, math, parseutils, base64, sha1, uri, lists,
dequ
So, change the whole language so you can copy-paste some FreeBasic stuff?
proc b()
proc a(n: int) =
b()
proc b() =
a(42)
Run
Forward declaration needed, [see here for a short
example/explanation](https://narimiran.github.io/nim-basics/#_forward_declaration)
Nim now has better documentation for four most used modules: `strutils`,
`sequtils`, `tables`, `math`.
See some [before and after screenshots](https://imgur.com/a/7pRwzfr).
* * *
But that is only a start, there is a lot of work remaining to be done, and
we're hoping for some help from our comm
Yesterday I have sent a mail to people on our leaderboard who solved 25 tasks.
If you're one of them and you didn't receive anything: first check your spam
folder ;) and if there's nothing there, please contact me.
Also, even if you didn't solve all 25 tasks, but you think some solution of
your
> If you want to work with matrices I advice you to work with a library like ...
... [Neo](https://github.com/unicredit/neo)
> More than willing, just need the documentation, ehem I mean guide :D , to
> contribute to documentation
"Congratulations, you played yourself" ;)
I started working on improving the documentation, by writing it for the most
used modules, such as `strutils`, `sequtils` and `tables`. After that
Here is my story from a slightly different angle.
I really like code-challenges sites. I've used them a lot (and: a lot of them
;)) when I was learning Python, and some of them when I started with Nim, here
is the list from the top of my head:
* Checkio
* Codewars
* Hackerrank
* Exercis
> Print only the elements of that array that are on odd indices (values 20, 40,
> …).
Ok, first thing you need it that exercise is to create an array and fill it
with values:
var a: array[10, int]
for i in 1 .. 10:
a[i-1] = 10*i
Run
Now comes the part you'
> The macor tutorial link leads to
> 404...[https://nim-lang.org/docs/tut3.html](https://nim-lang.org/docs/tut3.html)
Look at the original post at the top:
> We are aware that currently (until v0.19.4 is out) link to macro tutorial is
> broken. You can read the tutorial
> [here](https://nim-la
The first step towards better documented Nim is here, and it is an official
compilation of the existing learning resources (both official and from the
community) in one place:
[https://nim-lang.org/learn.html](https://nim-lang.org/learn.html)
This should allow an easier start for newcomers to N
For all the newcomers to Nim and people who would like to learn some new Nim
trick, there is now an official page at Nim website dedicated to that:
[https://nim-lang.org/learn.html](https://nim-lang.org/learn.html)
There you can find all the learning resources (both official and from the
commun
> So, the documentation can be improved, but saying that accomplishes nothing
> beyond the current status quo.
I started working on it.
It is a long process. Some of the things should be visible soon, some not so
soon, and for some others I hope for (and will need) the community involvement.
> And many won't take "Use VSC" as a satisfying answer. One example is the vim
> crowd. Another one is the sublime text crowd.
And why do you think that such crowds would take "use Aporia" as a satisfying
answer?
* * *
I think you're (too easily) dismissing people whose train of thought is "I
> What, for instance, will I respond to someone to whom I try promote Nim when
> he asks me (...) "Is there a good IDE"?
You respond: "Yes there is, use VS Code."
I just realized that on Nim homepage you need to scroll all the way to the
bottom (!) to see the "Learn Nim today" section, which just has a link to the
first part of the official tutorial.
IMO, we can do better than that. See the
[issue](https://github.com/nim-lang/website/issues/135) I've jus
Nim RFCs are transferred from nim-lang/Nim repo to a new home:
[https://github.com/nim-lang/RFCs](https://github.com/nim-lang/RFCs)
What this means is that you shouldn't open new issues in the main Nim repo to
discuss your proposals for the language anymore.
The idea is to have a more formal wa
One of the most frequent complaint about Nim is that it lacks proper
documentation. For example, it is mentioned in [2017 community
survey](https://nim-lang.org/blog/2017/10/01/community-survey-results-2017.html),
[2018 community
survey](https://nim-lang.org/blog/2018/10/27/community-survey-res
> choosenim supplies 0.19.0
Until this is fixed, after the installation run:
$ choosenim update stable
Run
> Many thanks to all the contributors who made these releases possible and Nim
> thrive.
Here are some quick numbers:
* 237 backported[1] commits since `v0.19.0` tag (September 26th), more than
2.5 commits per day on average
* 48 contributors
> there are rumors that with this release the
> for h in 0..H:
>
> for w in 0..W:
This is the source of your error — you're trying to do something at positions
`H` and `W`, and your array has `H` elements: from `0` to `H-1`.
To fix it, use `..<` which excludes upper limit:
for h in 0 ..< H:
for w in 0 ..< W:
If your `stack` and `p` are defined globally and at the beginning (before
`PUSH` and `POP` procs), you can do as simple as:
var
stack: array[10, int]
p = -1
proc PUSH(v: int) =
inc p
stack[p] = v
proc POP: int =
result = stack[p]
> var x: uint16 = 5.uint16
var x = 5'u16
> Do you guys have a favorite so far?
My favourites so far are probably:
1. day 5 (polymers)
2. day 8 (nodes and metadata)
3. day 9 (marbles)
> I'm still learning Nim (...) Not a programmer by trade and it might show.
I really like your solutions so far!
And if you didn't explicitly tell, I wouldn't ever have guessed that you're
just learning Nim nor that you're not a programmer.
> repo:
> [https://git.sr.ht/~king3vbo/advent-of-code/tree/master/2018](https://git.sr.ht/~king3vbo/advent-of-code/tree/master/2018)
"Your" solutions look quite nice, although [very
familiar](https://github.com/narimiran/AdventOfCode2018) ;)
I know that MIT license is quite permissive, but at l
> Constructors don't even have a consistent language convention. See `newSeq`
> vs `initCountTable`
See the first two lines of the big table here:
[https://nim-lang.org/docs/nep1.html](https://nim-lang.org/docs/nep1.html)
* `init` is used to create a **value** type `T`
* `new` is used to cr
> I am brand new to Nim, and was inspired by the Advent of Nim post
Glad to have you with us :)
> In my testing, `initIntSet()` turned out to be a lot faster than initializing
> with `initSet[int]()`
You're not using high enough number ;) Try it with something like `2^17`. There
should be a di
> The documentation for CountTable is autogenerated and lacking (no
> "description" explaining how to use CountTable).
This was improved during Hacktoberfest, but it has not yet hit the stable
version. For the devel docs of tables module (including a short example how to
use `CountTable`), see
> Something in the end I was not able to understand how to do is how to print
> the type of a variable.
There is a pending PR waiting to be merged which will allow this by default.
Until that is here, you need to `import typetraits`.
> my input file contained integer that did not fit in 16 bits
> Anyway, I have found a working solution now after a lot of research
_...and as a good citizen, I will post it here so when somebody after me
struggles with the same issue, can see how I managed to solve it._
> Inspired by @miran's repo
_blushing_ :)
> Nim (python-naive) implementation unexpectedly much slower! Why?
I know the answer, but you disabled issues in your repo so I cannot comment
there.
We had a long discussion on #nim IRC channel about this today, and there are
two possible solutions
> Currently there are 18 of us who joined.
Make that 38, as we speak ;)
Less than 24 hours to go until the start so here are some basic tips/rules:
1\. **SPOILERS** : Try to keep this thread as spoiler-free as possible. If you
can't wait to share your solution,
[r/adventofcode](https://old.red
Currently there are 18 of us who joined.
If you didn't participate in the previous incarnations of AoC and you don't get
what all the fuss is about, I'd recommend you to solve some tasks from 2017 (or
earlier) to get in the mood and join us this Saturday.
Usually first few days every year are e
> if Nim would have pattern matching
[https://github.com/alehander42/gara](https://github.com/alehander42/gara)
101 - 200 of 295 matches
Mail list logo