Hi
Just tried installing Nim following the directions from here
[https://nim-lang.org/install_windows.html](https://nim-lang.org/install_windows.html)
You _CAN_ do better than this.
For example why are you not linking to
@zevv, @cictycide. Thanks to both of you for your prompt offers of help. I've
posted an example of the issues for both of you.
Before and after with
before
proc vmJumpIfTrue(self: Computer) =
if self.s.processor.memory1 != 0:
self.s.processor.programCounter = self.s.processor.memory2
else:
self.s.processor.programCounter = self.s.processor.programCounter +
3
Stefan thanks for the prompt response. As ever, sometimes you just miss the key
tag for searching. The With package seems to do the trick and hasremoved a huge
amount of repetitive noise in object methods. I also tested Cascade but I
experienced problems.
I also followed up on inc but like +=
I'm having fun learning nim by converting Advent of Code solutions I wrote in
VBA.
In VBA you can shortcut long qualifiers using the With statement.
Private Sub VmEquals()
With s.Processor
.Memory3 = IIf(.Memory1 = .Memory2, 1, 0)
Sadly, having spent a little while scattering With's around some of my code it
appears that there are issues. Consequently I'm reverting back to var x = y
type statements
I'm currently having a bash at using nim by converting my efforts for Advent of
Code from VBA to nim. Unfortunately I've got stuck when trying to iterate over
the input from a file and push that input into an OrderedTable.
proc GetDay02Program(): OrderedTable[int64,int64] =
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?
Aha: success
for myKey, myValue in readFile(day02PathAndName).split(',').pairs():
result[myKey.int64]=myValue.parseInt
Run
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.
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
11 matches
Mail list logo