there is no split iterator that returns two values at a time. you're confusing
it with sequence and implicit pairs. you have to keep track of the indexes on
your own here.
On further reading it seems there is a split proc and a split iterator. The
former returns a sequence of substrings. The code I have seems to be using the
iterator version. How would I indicate to nim to use the proc rather than the
iterator version of split?
I'm using Raspbian on a Pi3 (and Pi2). The version of nim in the repo is fairly
old. I'm now just going with the simplest solution: using the nightly build
that I indicated above. It works, so I'm happy.
I'm using GCC v 8.3.0 on the Pi 2 and 3. I do most of my work on an x84_64.
I wrote a GitHub Actions to lint Nim code.
nimlint-action is inspired by
[reviewdog/action-eslint](https://github.com/reviewdog/action-eslint).
[https://github.com/jiro4989/nimlint-action](https://github.com/jiro4989/nimlint-action)
This action notices compile message to Pull Request.
Exam
invoke items/pairs iterator explicitly
Sorry for being lazy earlier and for my poor English. What I meant was this:
import strutils
var
file = """
Hello,World
Key,Value
"""
for line in file.split("\n"): # iterator returns string
var data = line.split(",") # proc returns s
As a shameless plug, but I made one of the most featureful Nim plugin for
neovim :) Check it out at
[https://github.com/alaviss/nim.nvim](https://github.com/alaviss/nim.nvim)
Still using this plugin lots - and works great!
One thing I'm wondering about is opening and closing sections. It's nice to
have top-level things collapsed when a file is first opened, and I can just
open the section I'm interested in. Only thing is, I'm not sure how to close a
section after it
I'll have to wait until my knowledge of nim improves before I can that. In the
meantime I'm using
let mySeq:seq[string]=readFile(day02PathAndName).split(',')
for myKey, myValue in mySeq:
result[myKey.int64]=myValue.parseint.int64
Run
Seems to be a use-case for Nim's csv parser,
[https://nim-lang.org/docs/parsecsv.html](https://nim-lang.org/docs/parsecsv.html)
It might be more productive if I advise you that I spent several days perusing
the nim documentation before I admitted defeat and asked a question here.
@Solitude's comments highlighted something that is not adequately referenced
when you read the for loop section of the manual.
Aha: success
for myKey, myValue in readFile(day02PathAndName).split(',').pairs():
result[myKey.int64]=myValue.parseInt
Run
Sorry, I made it a showstopper bug, will be fixed anytime soon now.
`zf` is for creating fold :) To close one you use `zc`. See `:h fold-commands`
for further folding magic.
> At present I can get cligen things (like that example bench above) to compile
> and run ok, but with gc:arc invoking with --help raises a HelpOnly exception
> that then dumps core. Current runtime seems to think the exception is
> unhandled. (Haven't looked into it further.)
[https://github.c
One thing I really hate about Nim is its use of whitespace, particularly in
regards for disallowing tabs. I've been going pluginless for a couple of years
now, and want to keep it that. I like to be able to get my installations from 0
to working in as little time as possible.
For some reason, I
Nowadays, with vim 8 & neovim's `packages` feature (see `:h packages`) it has
never been easier to maintain a full setup that you can just clone from your
git and got everything working right after :)
> For some reason, I couldn't get vim embedded instructions to do the tabs
> properly. I don't
Ah ok, thanks :)]
Thanks!
I had heard of `npegs`, but so far chose `pegs` because it's in the standard
library and understands standard PEG syntax. That said, `npeg`'s features are
very impressive. :-)
> Afaik, stdlib peg is designed for nim compiler itself and somewhat limited.
So I guess there's not much moti
A [demo](https://asciinema.org/a/276278) on debugging in neovim:
\--
I made this a long time ago, but forgot to share it on the forums.
This code:
let somePrimes: set[1..10] = {2, 3, 5, 7}
Run
gives:
Error: type mismatch: got but expected
'set[range 1..10(int)]'
Run
How do I initialize a set of range?
Like so:
type OneTo10 = range[1..10]
let somePrimes = {2.OneTo10, 3, 5, 7}
Run
> fully document this change.
I'm waiting for a bug report because I bet it is a bug and not the deliberate
choice to map IndexError et al to quit. Consider that code that catches these
errors already was broken with `-d:danger` too and for years `-d:release` was
what is now `-d:danger`.
When I compile the following code:
import strutils
type
Token {.exportc.} = object
typ: cint
val: cstring
proc exportc(a: Token) {.exportc.} =
let msg = "Token (type, value): ($1, $2)" % [$a.typ, $a.val]
echo msg
Run
Well, changing to inherit from `CatchableError` did not alone fix things
(though that is clearly a thing I should have done long ago, and I think
separating bugs from unusual control flow is a Good Thing). I did catch these
when compiled with `-d:danger/-d:release` for the past 2.5 years, though
var x {.compileTime.} = false
static:
x = true
echo x
Run
> false
26 matches
Mail list logo