Download nim-2.0.2_x64.zip for windows 11 will be blocked by Windows Defender.

2024-02-26 Thread freeflow
I am an amateur who programs in Visual Basic for Application. Pull requests are 
a magic incantation with which I have no familiarity.


Download nim-2.0.2_x64.zip for windows 11 will be blocked by Windows Defender.

2024-02-26 Thread freeflow
Widows defender has a built in facility that allows the user to disable it for 
a short period. This allows 'problematical' files to be downloaded without any 
virus blocking. Defender automatically reinitialises after a short period.

The setting is Settings->'Virus & threat protection'->'Virus & threat 
protection settings'->'Real-time protection'

Maybe this information should be added to the windows download instructions.


issues trying to install nim

2024-02-18 Thread freeflow
I had the same problem and response. In fact, Windows allows you to temporarily 
suspend defender for exactly this situation. See settings.WIndows 
Security.Virus & Threat protection settings.Realtime protection


`nph` opinionated formatter v0.3

2024-01-09 Thread freeflow
NO worries. I've looked at nph and have now dumped it. The two space tabbing is 
too small for my aged and decrepid eyesight.


`nph` opinionated formatter v0.3

2024-01-09 Thread freeflow
What you are learning is that nph should not be enforcing a style but rather a 
view. i.e. nph can take nim however it is written and then present it in the 
ide in a format preferred by the user.

Using this approach it does not matter how much people disagree on a specific 
format because everyone can have a view that suits their preferences and 
because nph presents a view rather than restructuring the original code it 
makes it easier to maintain library code in the standard 'library' view.

Possibly more of a challenge than you were looking for.


`nph` opinionated formatter v0.3

2024-01-06 Thread freeflow
Even more tongue in cheek, did you accept the status quo when you invented nim. 
Should everyone using nim switch back to c++. Should Newton just have shrugged 
his shoulder when he saw the apple fall from the tree. I think you've done 
a great service by inventing nim, but even you needed nim 2.0.


`nph` opinionated formatter v0.3

2024-01-06 Thread freeflow
I would present a different opinion. nph is about the visual representation of 
the structure of the program. For this reason I would expect the fact that 'of' 
belongs to 'case' to be indicated by an indent relative to the 'case'. I'm 
struggling to see how the 'belonging' would be shown if not by an indent.


`nph` opinionated formatter v0.3

2024-01-05 Thread freeflow
I had a set of chained replaces that were set out as a vertical list


  .replace(x1, y1)
  .replace(x2, Y2)
  .replace(X3 ,Y3)


Run

these were reformated to fill the line length with splits being int he middle 
of the paramters


  .replace(x1,y1).replace(
  X2,Y2).replace(X3,Y3) etc


Run

I refactored the seq of replaces to iterate over a seq


let mySwaps = @[(x1,y1),(x2,y2),(x3,y3][(x10, y10)]


Run

this was 'nicely' reformatted to


let
  mySwaps =
@[
  (x1,Y1),
  (x2,Y2),
  
  (x10,y10)
]


Run

 Now, given the reformatting of mySwaps above, I'm 
struggling to understand why, in a language that uses indentation to enforce 
structure, the 'of' in case statements is aligned with the 'case' rather than 
being indented. I would have expected the 'of' statements to be indented with 
respect to the case. 


Reinstallation woes

2023-12-31 Thread freeflow
For info. The 64 bit nim installer is currently being blocked by Windows 
Defender

The threat reported is

Trojan:Script/Wacatac.B!ml

Having deleted the .choosenim, .nimble directories and purged nim references 
from my Path, choosenim stable --firstinstall (run in administrator terminal) 
is also refusing to install, presumably for the same reason.

That's on Windows 11


Advent of Nim 2023

2023-12-07 Thread freeflow
Wow. Thanks for taking the time to look at my code. The video was very 
interesting and provided lots of points for me to follow up. I must admit to 
having a red face (embarrassment) in response to some of your comments, but 
that's the danger of asking for feedback.

Thanks again.


Advent of Nim 2023

2023-12-06 Thread freeflow
In response to comments, running with 'nim compile -d:release -d:danger 
--verbosity:0 --hints:off --run' gives a time of 24 seconds (vs 480).


Advent of Nim 2023

2023-12-06 Thread freeflow
I don't. I'm comparing it against something that also doesn't have 
representative performance. The comparison is for fun only.


Advent of Nim 2023

2023-12-06 Thread freeflow
I'd expect nim to be comparable or faster than the twinbasic version of the 
solution. The results I have for days 1 to three are


|Day |twinBasic| Nim|
||||
|1   | 19.5 ms| 47 ms  |
|2   | 7.8 ms | 47 ms  |
|3   | 265 ms | 29 ms  |
|4   | 265 s  | 480 ms |


Run

I'm as a relative newcomer to nim and not a professional programmer I'm sure 
that looking at others code will be helpful (as it has already been), but I was 
hoping for more along the lines on comments on the specific bits of nim that I 
am using. my nim solutions are effectively direct translations of the twinBasic 
so I was expecting that the efficiency of nim would win over a programming 
language that is in beta and has no optimisations. 


Advent of Nim 2023

2023-12-04 Thread freeflow
I'd appreciate some insights. My Day 4 nim solution runs in around 480 seconds. 
my twinBasic (VBA) version runs in 265. I know its a brute force algorithm I'm 
using but I'd appreciate some explanation about what I'm doing that causes the 
nim version to run so slowly. The link I posted above is now public.


Advent of Nim 2023

2023-12-02 Thread freeflow
@PMunch apologies. It is public now. Using github is on the edge of my 
abilities.


Advent of Nim 2023

2023-12-02 Thread freeflow
my attempts here. I'm not a professional programmer and think in VBA. 


Thus far, as a totally unfair comparison (because I have no idea about setting 
things up to be comparable) Day 01 nim 38 ms, twinBasic 19.5 ms Day 02 nim 47 
ms, twinBasic 7.8 MS


Nim Community Survey 2023

2023-11-19 Thread freeflow
Its the general impression I have from reading this forum over the past few 
years. Citing a few recent changes doesn't change that impression.


Nim Community Survey 2023

2023-11-18 Thread freeflow
Curious as to why you are running a survey when the frequent feedback in this 
forum is routinely ignored.


What's stopping Nim from going mainstream? (And how to fix it?)

2023-11-04 Thread freeflow
I'd agree on the points that the nim environment is quite poor. Gives the 
impression of a language that is not adequately supported. To interest people 
in nim you need to find the pain points in other languages and show how nim 
solves these issues (at zero cost to the programmer). I'd also argue that these 
days, you probably also need to be providing input transpilers. E.g. If I can 
convert my existing code to nim at zero cost its much easier to compare and 
contrast.


+= operator with if statement gives errors

2023-04-17 Thread freeflow
Thanks for the feedback, the suggestions give me a workaround. But I'm still 
interested in understanding the Why


+= operator with if statement gives errors

2023-04-17 Thread freeflow
I'd appreciate a pointer as to why I'm getting two errors for this line of code 
one for the + in += One for 'if myMoves == UP: 1 else: -1'


myFloor += if myMoves == UP: 1 else: -1



Run

myfloor is defined as int, myMoves is derived from 'for myMoves in s.data' 
where s.data is a string and UP is '('


strutils: mapIt: empty seq gives index error

2023-01-10 Thread freeflow
Yes, its an issue with min. My apologies for time wasting. I just refer you to 
the last line of my op.


strutils: mapIt: empty seq gives index error

2023-01-10 Thread freeflow
Thanks for the feedback.

my comment came from this


if myNewTracks.len > 0:
var myTrackMin: int = myNewTracks.mapIt(it.len).min  - 1
if myTrackMin < myMin:
myMin = myTrackMin


Run

where myNewTracks is a seq[seq[Coord]] and Coord is an object of col:int, 
row:int

The test for zero was added because I was getting the error message at the 
mapIt line.

my assumption is that the mapIt gives me a sequence of int (the lengths of the 
inner seq) and I then find the minimum value from that new seq.


strutils: mapIt: empty seq gives index error

2023-01-10 Thread freeflow
I'm seeing this error when I pass an empty seq to mapIt


C:\Users\slayc\.choosenim\toolchains\nim-#devel\lib\system\fatal.nim(54) 
sysFatal
Error: unhandled exception: index out of bounds, the container is empty 
[IndexDefect]
Error: execution of an external program failed: 
'c:\Users\slayc\source\repos\AdventOfCode\Nim\nim2022\src\MainModule.exe'


Run

Of course I can avoid this error by testing for len = 0 but I was wondering if 
I should raise this as an issue as mapIt should probably handle an empty 
sequence a bit more gracefully.

Looking at the code for mapIt it doesn't seem that there is an explicit test 
for an empty seq.

I am not a novice at nim programming. Such a claim would be implying I have far 
more competence and capability than in reality.


A seasoned programmer's take on Nim's docs

2023-01-04 Thread freeflow
If you don't want folks to look at the nim manual as a tutorial then you should 
say so in the first paragraph of the manual and give a link to one or more 
tutorials. Taking the table you provided ,why not include that in the first 
paragraph of each of the types with links to appropriate sections.


A seasoned programmer's take on Nim's docs

2023-01-04 Thread freeflow
A good example of the style of documentation that makes things difficult for 
beginners is the 'Iterators and the For statement' section in the Nim manual. 
From a beginners perspective this might be better presented as two sections, 
one about the For statement, the second about iterators and their use in for 
loops to enable 'for each' style loops.

There is no mention of 'For' in the contents under the 'Statements and 
expressions' part of the contents column.

The 'for' section might be simpler by starting with the use of 
countup/countdown to closer link to for loops in other languages

Then a discussion on how to implement the equivalent of for each using 
iterators.

Just an observation.


Strange error: single character string constants

2022-12-27 Thread freeflow
Indeed, I continue to explore how nim can be used better. I now have those 
single character string defined as chars and am experimenting with


type
direction = enum
North = (0,  $twHat)
East = (1, $twRAngle
South = (2, "v")
West = (3, $twLAngle)


Run

and I've moved the individual blizzard seq into a Table


s.Blizzards=[$North: newSeq[Point](), $East: newSeq[Point], $South; 
newSeq[Point](), $West: newSeq[Point}()}.toTable


Run

which is working well, although I couldn't understand why


s.Blizzards = {$North; @[], $East:  @[], $South: @[],  $West: @[]}.toTable


Run

refused to compile even though s.Blizzards has been assigned the Type of 
Table[string, seq[Point]] 


Strange error: single character string constants

2022-12-27 Thread freeflow
I think I've located the cause of the issue.

The constants


const WALL : string = twHat
const PATH : string = twPeriod
const EAST : string = twLAngle
const WEST : string = twRAngle
const NORTH: string = twHat
const SOUTH: string = "v"


Run

are used in a single location to convert strings to set of x,y coordinates.

the problem test data set is


#E##
#>>.<^<#
#.<..<<#
#>v.><>#
#<^v^^>#
##.#


Run

myData is a seq of strings representing the above dataset this dataset is 
converted to sets of x,y coordinates using


s.FinalXY = (myData.first.find(twHash),myData.low)
s.Current = (myData.last.find(twHash),myData.high)

for myRow in s.MinRow..s.MaxRow:
for myCol in s.MinCol..s.MaxCol:
let myChar: char =  $mydata[myRow][myCol] *
case myChar
of WALL:
s.Wall.add((myCol, myRow))
of NORTH:
s.NorthB.add((myCol, myRow))
of SOUTH:
s.SouthB.add((myCol, myRow))
of WEST:
s.WestB.add((myCol, myRow))
of EAST:
s.EastB.add((myCol, myRow))
else:
discard


Run

the line highlighted with  had been giving me an error at the [mycol] when 
myChar was defined as string, so I'd changeed it to char which leads to a 
mismatch between the constant declarations and the case variable. type.

changing


let myChar: char =  mydata[myRow][myCol]


Run

to


let myChar: string =  $mydata[myRow][myCol]


Run

resolves the problem with twHash but now leaves me with an error of '


C:\Users\x\source\repos\AdventOfCode\Nim\AoCLib\src\chars.nim(20, 45) 
Error: duplicate case label


Run

which is the line


const twHat  : string = "^"


Run

If I rewrite the case statement using the tw strings directly


for myRow in s.MinRow..s.MaxRow:
for myCol in s.MinCol..s.MaxCol:
let myChar: string =  $mydata[myRow][myCol]
case myChar
of twHash:
s.Wall.add((myCol, myRow))
of twHat:
s.NorthB.add((myCol, myRow))
of "v":
s.SouthB.add((myCol, myRow))
of twLAngle:
s.WestB.add((myCol, myRow))
of twRAngle:
s.EastB.add((myCol, myRow))
else:
discard


Run

All errors go away and I get a successful compile.


Strange error: single character string constants

2022-12-26 Thread freeflow
Apologies if I'm sowing confusion. I'm just a complete amateur programmer 
looking for something to test solutions when VBA/twinBasic takes too long or 
has memory issues. Nim seemed to fit the bill really well, especially as the 
syntax allows an almost 1:1 mapping from VBA to nim. I just have to remember 
that VBA passes parameters by reference and nim by value. It causes some 
entertainment (late night frustration) on occasion.

This was the original file that was leading to the error message when I it was 
imported as '../../AoCLib/chars'. There are two blank lines before the first 
line below.



#\r, \c carriage return
#\n, \l line feed
#\f form feed
#\t tabulator
#\v vertical tabulator
#\\ backslash
#\" quotation mark
#\' apostrophe
#\ '0'..'9'+character with decimal value d; all decimal digits 
directly following are used for the character
#\a alert
#\b backspace
#\e escape [ESC]
#\x HH  character with hex value HH; exactly two hex digits are allowed
consttwNoString* : string = ""
consttwHat*  : string = "^"
consttwBar*  : string = "|"
consttwComma*: string = ","
consttwPeriod*   : string = "."
consttwSpace*: string = " "
consttwHyphen*   : string = "-"
consttwColon*: string = ":"
consttwSemiColon*: string = ";"
consttwHash* : string = "#"
consttwPlus* : string = "+"
consttwAsterix*  : string = "*"
consttwLParen*   : string = "("
consttwRParen*   : string = ")"
consttwRAngle*   : string = ">"
consttwLAngle*   : string = "<"
consttwAmp*  : string = "@"
consttwLBracket* : string = "["
consttwRBracket* : string = "]"
consttwLCurly*   : string = "{"
consttwRCurly*   : string = "}"
consttwPlainDQuote*  : string = "\""
consttwPlainSQuote*  : string = "'"
consttwLSmartSQuote* : string = "‘" #ChrW$(145)   ' Alt+0145
consttwRSmartSQuote* : string = "’" #ChrW$(146)   ' Alt+0146
consttwLSMartDQuote* : string = "“" #ChrW$(147)   ' Alt+0147
consttwRSmartDQuote* : string = "”" #ChrW$(148)   ' Alt+0148
consttwTab*  : string = "\t"
consttwCrLf* : string = "\r\n"
consttwLf*   : string = "\n"
consttwCr*   : string = "\c"
consttwNBsp* : string = "\255" #Chr$(255)


Run

which came from the VBA file


Public Const twHat  As string = "^"
Public Const twEqualAs string = "="
Public Const twLArrow   As string = "<"
Public Const twRArrow   As string = ">"
Public Const twNoString As String = ""
Public Const twBar  As String = "|"
Public Const twCommaAs String = ","
Public Const twPeriod   As String = "."
Public Const twSpaceAs String = " "
Public Const twHyphen   As String = "-"
Public Const twColonAs String = ":"
Public Const twSemiColonAs String = ";"
Public Const twHash As String = "#"
Public Const twPlus As String = "+"
Public Const twAsterix  As String = "*"
Public Const twLParen   As String = "("
Public Const twRParen   As String = ")"
Public Const twAmp  As String = "@"
Public Const twLBracket As String = "["
Public Const twRBracket As String = "]"
Public Const twLCurly   As String = "{"
Public Const twRCurly   As String = "}"
Public Const twBSlash   As string = "\"
Public Const twFSlash   As string = "/"
Public Const twPlainDQuote  As String = 
Public Const twPlainSQuote  As String = "'"
Public Const twLSmartSQuote As String = "‘" 'ChrW$(145)   ' Alt+0145
Public Const twRSmartSQuote As String = "’" 'ChrW$(146)   ' Alt+0146
Public Const twLSMartDQuote As String = "“" 'ChrW$(147)   ' Alt+0147
Public Const twRSmartDQuote As String = "”" 'ChrW$(148)   ' Alt+0148
Public Const twTab  As String = vbTab
Public Const twCrLf As String = vbCrLf
Public Const twLf   As String = vbLf
Public Const twCr   As String = vbCr
Public Const twNBsp As String = "ÿ" 'Chr$(255)


Run

I 

Strange error: single character string constants

2022-12-26 Thread freeflow
Thanks for the reply. As you can surmise this is an Advent of Code problem. My 
original solutions were written in the new twinBasic dialect of VBA. I have a 
simple VBA macro that does some search and replaces which gets VBA/twinBasic 
code to 90% nim syntax.

twinBasic/VBA doesn't have char Types hence the single character strings. I 
actually implemented your proposal before reading the above and all works as it 
should.


Strange error: single character string constants

2022-12-26 Thread freeflow
The line **is**


consttwHash* : string = "#"


Run

but as you can see from my response to Araq I've since converted the single 
character strings to chars and now don't see any errors.a


Strange error: single character string constants

2022-12-26 Thread freeflow
I have defined some single character string constants which sit in their own 
'chars.nim' file.


consttwHat*  : string = "^"
consttwBar*  : string = "|"
consttwComma*: string = ","
consttwPeriod*   : string = "."
consttwSpace*: string = " "
consttwHyphen*   : string = "-"
consttwColon*: string = ":"
consttwSemiColon*: string = ";"
consttwHash* : string = "#"
consttwPlus* : string = "+"
consttwAsterix*  : string = "*"
consttwLParen*   : string = "("
consttwRParen*   : string = ")"
consttwRAngle*   : string = ">"



Run

When I compile I'm seeing a single error but I cannot work out the cause.


: used config file 
'C:\Users\XX\.choosenim\toolchains\nim-#devel\config\nim.cfg' [Conf]
Hint: used config file 
'C:\Users\XX.choosenim\toolchains\nim-#devel\config\config.nims' [Conf]

.
C:\Users\XXc\source\repos\AdventOfCode\Nim\nim2022\src\chars.nim(25, 
45) Error: type mismatch: got 'string' for '"#"' but expected 'char'



Run

output of nim -v is


Nim Compiler Version 1.9.1 [Windows: amd64]
Compiled at 2022-12-25
Copyright (c) 2006-2022 by Andreas Rumpf

active boot switches: -d:release


Run

Please note that I am an extreme novice when it comes to setting up VSCode for 
working with nim.


Importing from a parallel directory.

2022-11-04 Thread freeflow
As is always the case the answer came after I'd posted the question. It is , of 
course


../../libs/constants


Run

It would have been nice to have found this in the manual/tutorial


Importing from a parallel directory.

2022-11-04 Thread freeflow
Another newcomer question

I think I've read a considerable amount on import files in nim but for the life 
of me I can't figure out how to import from a parallel directory

File structure


/nim/project/src/main.nim

/nim/libs/constants.nim


Run

How do I import constants into main?


Novice Question: Implement the Step functionality in VBA

2022-01-21 Thread freeflow
That worked fine. I also used a version of it in C# to resolve a similar 
nastinees.

Cheers.


Novice Question: Implement the Step functionality in VBA

2022-01-14 Thread freeflow
That's a neat solution but isn't appropriate in this case. The iteration has to 
be X1 to X2 because the x values are tied to Yvalues and your suggestion would 
change the x,y pairs.

In the meantime I've come up with the ghastly apparition of


iterator myStep( a,b: int):int=

var a1 = a
var b1 = b
if a<=b:

while a1<=b1:
yield a1
inc a1

else:

while a1>b1:
yield a1
dec a1


Run

but won't be able to test it until monday 


Novice Question: Implement the Step functionality in VBA

2022-01-14 Thread freeflow
I'm converting Advent of Code solutions from VBA (twinBasic) to Nim

I have a bit of a headscratcher when it comes to implementing the Step 
functionality in 'for x to y step z' because in VBA step can be a positive or a 
negative value wheres nim uses countup or countdown iterators with the step 
value always being a positive number


Dim myXStep As Long = If(s.X1 <= s.X2, 1, -1)
 For myXCoord = s.X1 To s.X2 Step myXStep


Run

I tried being clever with this code in nim


var myXStep:iterator [T](a, b:T): T   = if s.X1 <= s.X2: [T]countup(a,b:T) 
else: [T]countdown(a,b:T)


Run

so that I could then write


for myX in myXstep(s.X1,s.X2)


Run

but it doesn't work, even when I convert the 1 line version to a multiline 
version

I have elsewhere successfully used something similar to the above to provide 
procs as a parameter but I'm obviously not quite there yet with the above 
attempts.

Advice would be welcome.


Links to Std library lead to a 404

2022-01-02 Thread freeflow
Hi. Just thought I'd report that links on this page



just give a 404


Nim with curly brace and tab

2021-12-21 Thread freeflow
ci) means change inside parentheses in French, German , Italian, 
Japanese


Nim with curly brace and tab

2021-12-21 Thread freeflow
With a mouse it should be position your cursor anywhere between the parentheses 
click again to select the symbol, click again to expand the selection to the 
current parentheses etc, fistart typing

with vim ci) after first having spent 18 month learning the convoluted non 
intuitive key sequence (a la vscode) to perform the magic.


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-09 Thread freeflow
I can make State an object. Does it really need to be exported as it is used 
only within the module in which it is declared.


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-09 Thread freeflow
@Araq. Thanks for taking the time to respond. I can confirm that there is no 
such item as BoardsAsNumbersrnalErrorFlag in my AoC2021 project. I do have a 
field in a module level tuple that has part of the same name. I'm happy to post 
a link to the repository if that's helpful.


State = tuple
Data: seq[string]
DrawnNumbers:seq[int]
BoardsAsNumbers:seq[seq[seq[int]]]
Boards:seq[Board]
Win:bool
Answer:int


Run


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-09 Thread freeflow
I've got day04 code than is now 'clean' in VSCode by changing from echo fmt to 
just echo. However I'm still seeing the compiler error out with 


[Running] nim compile --verbosity:0 --hints:off --run [Running] nim compile 
--verbosity:0 --hints:off --run 
"c:\Users\*\source\repos\AoC2021\Nim\Sources\Main.nim"
C:\Users\*\.choosenim\toolchains\nim-1.6.0\lib\core\macros.nim(533, 3) 
Error: undeclared identifier: 'BoardsAsNumbersrnalErrorFlag'
candidates (edit distance, scope distance); see '--spellSuggest':
 (13, 2): 'internalErrorFlag' [proc declared in 
C:\Users\*\.choosenim\toolchains\nim-1.6.0\lib\core\macros.nim(525, 6)]


Run

Should I raise this as a compiler issue?


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-09 Thread freeflow
@shirleyquirk That's what I would normally try to do, particularly if I was 
playing in VBA (my normal amateur hunting grounds). With nim it seems to me 
that the echo fmt error is related to an mistake that has been made far far 
away so tracking down a concise example can be difficult for a nim newbie like 
myself. I know some forums, like stack overflow, don't like links, but would it 
be acceptable here to post a link to a git repository?


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-08 Thread freeflow
Once again I deleted the .nimble and .Choosenim directories, rebooted, 
reinstalled by Choosenim . Days1,2,3 are now OK but I still have echo fmt 
issues in Day04.


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-08 Thread freeflow
Unfortunately, the problem has returned. On compilation I'm seeing


[Running] nim compile --verbosity:0 --hints:off --run 
"c:\Users\*\source\repos\AoC2021\Nim\Sources\Main.nim"
C:\Users\slayc\.choosenim\toolchains\nim-1.6.0\lib\core\macros.nim(533, 3) 
Error: undeclared identifier: 'BoardDatarnalErrorFlag'
candidates (edit distance, scope distance); see '--spellSuggest':
 (8, 2): 'internalErrorFlag' [proc declared in 
C:\Users\*\.choosenim\toolchains\nim-1.6.0\lib\core\macros.nim(525, 6)]



Run

This occurs even when completely deleting my Day04 code leaving only code for 
Day1, 2 and 3 which previously compiled without issue.


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-08 Thread freeflow
@shirleyquirk. Understood. I'll do better next time if including code.

In the meantime the good news is that I tracked down and deleted all nim 
related things on my PC, including path stuff. Reinstalled nim using choosenim 
and the problem has now gone away. SO it looks like yesterdays deletion of a 
duplicate installation wasn't quite enough.


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-08 Thread freeflow
@SolitudeSF. My apologies, but that's all the code there was . What else should 
be above to make a 'snippet'


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-08 Thread freeflow
@aEverr. If I go to the terminal in VSCode and type Choosenim Stable and nim I 
get the following 


PowerShell 6.2.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS C:\Users\\source\repos\AoC2021\Nim> choosenim stable
  Info: C:\Users\\.choosenim\downloads\dlls.zip already downloaded
 Extracting dlls.zip
  Info: Version 1.6.0 already selected
PS C:\Users\\source\repos\AoC2021\Nim> nim --version
Nim Compiler Version 1.6.0 [Windows: i386]
Compiled at 2021-10-19
Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 727c6378d2464090564dbcd9bc8b9ac648467e38
active boot switches: -d:release -d:danger
PS C:\Users\\source\repos\AoC2021\Nim>


Run


More nim newbie woes, this time echo fmt Possible AOC2021 spoiler

2021-12-08 Thread freeflow
I have the following code 


import strformat
import sequtils
import strutils
import parseutils

import Constants
import Support

const InputData = "Day04Test.txt"

type
Board = tuple
Numbers :seq[int]
Ranks: seq[seq[int]]

var s :tuple[ Data: seq[string], DrawnNumbers:seq[int], 
BoardNumbers:seq[seq[seq[int

s.Data = readfile(RawDataPath & InputData).multireplace(("  "," 
")).split("\r\n\r\n",1)

echo fmt" Data {s.Data}"


Run

The echo fmt line is underlined from the opening " to the closing ". Two errors 
are reported.

When the cursor is at the opening "


template/generic instantiation of `fmt` from here
template/generic instantiation of `fmt` from here

Error: internal error: 
/home/runner/work/nightlies/nightlies/nim/compiler/vmgen.nim(1576, 22)
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp check ', 
see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for 
details


Run

Anywhere else that is underlined 


template/generic instantiation of `fmt` from here

Error: internal error: 
/home/runner/work/nightlies/nightlies/nim/compiler/vmgen.nim(1576, 22)
No stack traceback available
To create a stacktrace, rerun compilation with './koch temp check ', 
see https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler for 
details


Run

Would someone be kind enough to point out what needs to be changed (apart from 
deleting all the code :-) ) to eliminate these issues. I've tried but can't 
fathom it.


sequtils.CountIt not recognised - Possible AoC2021 spoiler

2021-12-07 Thread freeflow
Sorted, seems like I had a double installation. nim is now reporting 1.6.0 and 
countit is recognised


sequtils.CountIt not recognised - Possible AoC2021 spoiler

2021-12-07 Thread freeflow
Or perhaps not.

Choosenim stable reports that 1.6.0 is installed nim - h reports that version 
1.0.4 is being used.

what do I do next?


sequtils.CountIt not recognised - Possible AoC2021 spoiler

2021-12-07 Thread freeflow
@SolitudeSF Thanks for the feedback. I'm using nim version 1.6. I'm doing 
advent of code in nim as a challenge from amateur coding (i don't get paid...) 
in VBA. So there are lots of concepts in nim I need to get my head around. Look 
like tonighht's reading is about when and where to use new.


sequtils.CountIt not recognised - Possible AoC2021 spoiler

2021-12-07 Thread freeflow
@yhfle, @SolitudeSF. Compilation fails with 'attempting to call undeclared 
routine: 'countIt''

@minran To be equally opaque, why why?


For loop using iterator `..`

2021-12-07 Thread freeflow
I feel your pain. Nim is so good you are encouraged to explore without reading 
the manual, then you get tripped up by a template It only took me about 
10 mins to find countdown to resulve the same issue.


sequtils.CountIt not recognised - Possible AoC2021 spoiler

2021-12-07 Thread freeflow
I'm using import sequtils. FilterIt and MapIt work fine, but countIt is not 
recognised despite being in the documentation for seqUtils. What am I doing 
wrong?


import strformat
import sequtils
import Constants
import Support

const InputData = "Day03Test.txt"

type
  State =tuple[ Data: seq[seq[char]], Transposed :seq[seq[char]]]

let s = new State
s.Data = toSeq((RawDataPath & InputData).lines).mapit(it.toseq())
s.Transposed = s.Data.Transpose()

proc Part01() =
var
myOnes:int
myGamma,myEpsilon:string

for myitem in s.Transposed:
myOnes=myitem.countIt(it=='1')  ' countIt is underlined with the 
error message 'attempting to call undeclared routine'


Run


Order of execution: where to find understanding

2021-12-02 Thread freeflow
@PMunch. Apologies, I was trying to attach my reply to the comment by @Argl but 
messed up so instead they got added as general comments. Whilst I could edit to 
remove the text, I wasn't allowed to delete the (now empty) comments.

Thanks for the explanation. The analagous situatione in VBA would be code the 
Class_Initialize method. Such code is run the first time an instance of the 
class is encountered on the RHS of an expression.


Order of execution: where to find understanding

2021-12-02 Thread freeflow
Kind, thoughtful, considerate - not


Order of execution: where to find understanding

2021-12-02 Thread freeflow
Kind, thoughtful, considerate - not!!


Order of execution: where to find understanding

2021-12-02 Thread freeflow
@jyapayne Mainly VBA and a little bit of C#. I'm not a professional programmer. 
I'm not used to code that is not enclosed in a Method (procedure definition) 
inside a names module or class . In VBA the let statement above would be 
illegal. I wanted to read up on it to be aware of what I can and can't do with 
such 'unwrapped code'

I'm still waiting for a pointer to a document/reference.


Order of execution: where to find understanding

2021-12-02 Thread freeflow
Kind, thoughtful, considerate - not!!!


Order of execution: where to find understanding

2021-12-02 Thread freeflow
Can someone point me to which document describes the order of execution of code 
in files. In particulate why the let statement in the code below executes 
before any of the procs.

In file Day01.nim 


import strutils
import strformat
import sequtils
import Constants

const InputData = "Day01.txt"


type
  State = object
Integers: seq[int]

let s =State( Integers:toSeq((RawDataPath & InputData).lines).map(parseInt) 
)

proc Part01() =

var myResult:int=0
for myIndex in 1..

proc Part02() =

var myResult:int=0
var mySum:seq[int]

for myindex in 2..

proc Execute*()=
Part01()
Part02()


Run

In file Main



import Day01

Day01.Execute()


Run


Advent of Nim 2021

2021-12-01 Thread freeflow
Here are my efforts.




Nim 2.0 -- thoughts

2021-06-24 Thread freeflow
I am a bear of very little brain but recently, during a prolonged wrestling 
match with the type system in Visual Basic for Application' I think I had an 
interesting idea namely that Types, per se, are a case of premature 
optimisation.

It seems to me that Types come with a whole host of hidden assumptions which 
are difficult or impossible for a programmer to modify or maniplulate. Having 
played a little with nim for some Advent Of Code problems I thought nim might 
be a good candidate for opening up what makes up a type.

So instead of Types being black boxes what if they were replaced by collection 
of policies and the issue of how many bits to used to implement those policies 
being wholly transferred to the responsibility of the compiler.

The policies would be very simple things like that describe what operations may 
be performed on a block of memory

• Writable • readable • persistent • PositionalSymbols ' each symbol in a 
literal is x times the one to the left • SequenceSymbols ' a symbol array/list 
• SymbolEnum(Unicode,Ansi etc etc etc) • Incrementable (also means 
decrementable) and so on.

I'll go get my coat.


A VBA library?

2021-01-24 Thread freeflow
For the past couple of years I have attempted Advent of Code puzzles in VBA. 
The repetitevness of the VBA code I was writing led me to devise a super 
flexible dictionary object library in C# which helped enormously in removing a 
lot of boilerplate code and enabling operations not normally easily available 
in VBA code.

As an exercise to occupy my hours during Covid lockdown, I was wondering if a 
similar dictionary ( a Com object accessed by Interop) could be achieved in Nim.

>From my perspective the most challenging piece is the interop part.

I'd be enormously grateful for any pointers as to where I would start.

I have used nim a little to write some solutions to advent of code 2019 puzzles.


Finally found a language which is as fast as C and as Pythonic as possible...

2020-12-25 Thread freeflow
All but two of those links fail.


Seq, table. How to efficiently reference the last item

2020-12-15 Thread freeflow
The keys for the Orderedtable arrive in a random sequence and may be repeated.

The sequence associated with each key stores the step number on which the key 
arrives.

If I get Keys of 3,2,5,9,2,3, the sequences for key 3 and 2 would have two 
items each (1,6) and (2,5) for Keys 2 and 3.

If I ask for the last key in the ordered table I expect to be given the value 9.

If I ask for the last item in the sequence attached to Key 3 I expect to get 5.

Coming from VBA where this expectation was met exactly, I may be making unknown 
assumptions about how nim works.

Is an orderedTable populated with seq a reasonable approach?


Seq, table. How to efficiently reference the last item

2020-12-15 Thread freeflow
Advent of Code 2020 Day 15.


Seq, table. How to efficiently reference the last item

2020-12-15 Thread freeflow
I have holes hence the use of a table.


Seq, table. How to efficiently reference the last item

2020-12-15 Thread freeflow
Taking tentative steps into nim coming from VBA by having a go at Advent of 
Code 2020

I have an OrderedTable[ int, seq[ int ] ]

what is the most nimy (minish, nithonic?) way to get the value of the last item 
of the last sequence in the table when you don't now the specific indeces.

At the moment I've got to

> myTable[ myTable.len ][ myTable[ myTable.len ].len ]

which looks profoundly ugly for nim.

The equivalent (using my libraries) for VBA would be

> WrappedScriptingDIctionary.getlast.value.getlast.value

which for VBA is 'wonderfully eloquent'

NB getlast returns a key/value pair ,so in the first instance returns an index 
vs WrappedScriptingDIctionary ,and is a method I added to a wrapping of the 
Scripting.DIctionary object)


Nim update failure

2020-10-30 Thread freeflow
Thanks. That worked. Nim 1.4.0 now installed 


Nim update failure

2020-10-30 Thread freeflow
Ooops. Mistyped when getting output for the post.

try the example below 


C:\WINDOWS\system32>choosenim update self
   Updating choosenim
[# ] 0mb 4kb/s
httpclient.nim(1053) downloadFile
Error: unhandled exception: 404 Not Found [HttpRequestError]

C:\WINDOWS\system32>choosenim update stable
   Updating stable
Downloading Nim 1.4.0 from nim-lang.org
[# ] 0mb 0kb/s
  Info: Binary build unavailable, building from source
  Info: C:\Users\slayc\.choosenim\downloads\nim-1.4.0.tar.xz already 
downloaded
 Extracting nim-1.4.0.tar.xz
   Building Nim 1.4.0
   Building tools (nimble, nimgrep, nimpretty, nimsuggest)
 Exception: Execution failed with exit code 1
etc


Run


Nim update failure

2020-10-30 Thread freeflow
I got the following when trying to update to Nim 1.4

C:WINDOWSsystem32>choosenim versions --installed
Channel: stable


Installed:


  * 1.2.0 (latest) 1.0.6 1.0.4



C:WINDOWSsystem32>choosenim self update --verbose Downloading Nim 0.7.4 from 
nim-lang.org

[# ] 0mb 0kb/s


Info: Couldn't download file from 
.
... Response was: 404 Not Found

Info: Binary build unavailable, building from source

[# ] 0mb 0kb/s


Info: Couldn't download file from 
.
... Response was: 404 Not Found
Error: Version 0.7.4 does not exist.


Nim website front page redesign (unofficial and WIP)

2020-08-13 Thread freeflow
If you know nim the you might accept the headings in {} but if you don't it 
just looks like the page hasn't rendered correctly. The colour theme is INMO 
just ghastly. I