Print Unicode names e.g 'SPACE', 'NO-BREAK SPACE', HORIZONTAL TAB

2021-06-28 Thread masiarek2
When I enter 1 in "runeAt()" \- I get error Hint: /Volumes/T5/bin/discard_with_comment [Exec] /Volumes/T7/Nim/_my_code_ex/discard_with_comment.nim(7) discard_with_comment /Volumes/T5/.choosenim/toolchains/nim-1.4.8/lib/pure/unicode.nim(80) runeAt /Volumes/T5/.choosenim/t

Print Unicode names e.g 'SPACE', 'NO-BREAK SPACE', HORIZONTAL TAB

2021-06-27 Thread masiarek2
I want to print the Unicode **NAMES** related to whitespace and control characters (ASCII code < 14) e.g 'SPACE', 'NO-BREAK SPACE', HORIZONTAL TAB, etc. # non-working Python code :-) import unicodedata, string for e in string.whitespace + unicodedata.lookup("GREEK SMALL LETTE

Improving the documentation: Roadmap, community engagement.

2021-06-06 Thread masiarek2
Nim Cookbook with examples

mixed bag seq: allow strings and int in a seq

2021-06-06 Thread masiarek2
how to get a 'mixed bag seq' in Nim. I probably need to learn about generics... In Crystal: mixed_bag_seq = [1, "aa"] Run here is Nim example that fails: proc foo(a: int|string): int|string = # works: both string and int accepted discard

strscans - Error: undeclared identifier: 'scanf'

2021-05-30 Thread masiarek2
bummer yes, it works fine in terminal. So the issue is related Visual Studio Code

strscans - Error: undeclared identifier: 'scanf'

2021-05-30 Thread masiarek2
one line of code "import strscans" results with error. What am I missing? Is it a bug? import strscans # error # Hint: used config file '/Volumes/T5/.choosenim/toolchains/nim-1.4.8/config/config.nims' [Conf] # Hint: used config file '/Volumes/T7/Nim/_my_code_ex/conf

reverse seq mitems

2021-05-29 Thread masiarek2
This is the closest to the Nim Cookbook. * yes, we need a a cookbook...

print dates in reversed order

2021-05-29 Thread masiarek2
Any improvements, shorter, more idiomatic (golf?) Nim? import times, algorithm var today = now() var sq: seq[string] for i in 1..3: var duration = initDuration(days = i) var next_day = today + duration sq.add($next_day.format(", dd-MMM-"))

Add total ratings for all Candidates (STAR Voting)

2021-05-25 Thread masiarek2
hi @Zoom, I really appreciate your feedback. Yes, I want to learn programming - so any feedback is very much appreciated. I am looking for a mentor to guide me: what to learn in what sequence, do's and dont's, etc. It sounds my first assignment is to learn using new types in my small educational

Add total ratings for all Candidates (STAR Voting)

2021-05-25 Thread masiarek2
hi Guys, Wow - I really appreciate your help! Would you give me permission to move your code to GitHub: This is a non-profit organization (STAR Voting) - so big THANK YOU! Test Case 'Use01' \- passed *

proc "repeat" is ambiguous - compiler warning maybe?

2021-05-25 Thread masiarek2
It sounds like this is by design- this is Nim’s way ... most of the time I love current behavior

proc "repeat" is ambiguous - compiler warning maybe?

2021-05-25 Thread masiarek2
It seems that the method call is being ambiguous ... Any other examples? I am learning looming for other potential gotchas... import sequtils var x = repeat("ab", 3) echo x.type, ": ", x# seq[string]: @["ab", "ab", "ab"] echo("\n *** now import both sequtils and

Add total ratings for all Candidates (STAR Voting)

2021-05-24 Thread masiarek2
ggplotnim installed without any hiccups. I started looking at your solution - but my brain exploded. I need 2 month to learn how ggplotnim works :-). Thank you!

Add total ratings for all Candidates (STAR Voting)

2021-05-24 Thread masiarek2
Add total ratings for all Candidates (STAR Voting). In future this is going to be read from a file... # Voting Simulation: Candidates in file header: A, B, C - "STAR Voting Method" # followed by line items - voter ballots - e.g.: # - first line 0,2,5 (zero star vote for A,

Error: cannot open file: fusion

2021-05-22 Thread masiarek2
hopefully this is idiomatic / correct Nim approach: import os, re for file in walkDirRec "/Volumes/T7/Folder/": if file.match re".*\.txt": echo file createDir "/Volumes/T7/Folder2/" # just to test creation of a folder # this is the actual solu

Error: cannot open file: fusion

2021-05-22 Thread masiarek2
wow - creating a new directory is very easy: createDir "/Volumes/T7/Folder2/" Run

Error: cannot open file: fusion

2021-05-22 Thread masiarek2
This helps: Maybe this can help:

Error: cannot open file: fusion

2021-05-22 Thread masiarek2
at this page: Example: import fusion/scripting withDir "subfolder": echo "Inside subfolder" echo "Go back outside subfolder" Run fails with error message: E

squeeze the sequence: remove empty strings

2021-05-21 Thread masiarek2
thank you!

squeeze the sequence: remove empty strings

2021-05-21 Thread masiarek2
What is the idiomatic way to squeeze (remove empty strings) the sequence # squeeze the sequence: remove empty strings import regex var name = "Hello,%20World@#!" var pattern = re"[^a-zA-Z!]" var sq1 = name.split(pattern) var sq2: seq[string] = @[] for i, e in

NimConf 2021

2021-05-21 Thread masiarek2
long live hackathon! @dom96 \- I would love to help with organizing the hackathon or NimConf - just keep in mind I am junior Nimmer in training...

string ( int, string and char) - convert into Table

2021-05-19 Thread masiarek2
thank you! Wow: Nim is a statically typed language and yet it can behave like a weakly typed language if we want it. Awesome!

string ( int, string and char) - convert into Table

2021-05-19 Thread masiarek2
I have this code in Ruby: s = """ a 1 bb 2 33 33000 """ a = s.split h = Hash[*a] puts h # {"a"=>"1", "bb"=>"2", "33"=>"33000"} Run How to achieve similar effect in Nim? I am looking for a flexible key accepting say these typ

Why Nim is *not* confused - which proc to call?

2021-05-14 Thread masiarek2
THANK YOU

Why Nim is *not* confused - which proc to call?

2021-05-14 Thread masiarek2
I am a beginner and learning about "Generic procs". How Nim finds the correct proc 'min' to call? I was expecting error message: ambiguous proc name 'min' \- add module to make it clear which 'min' proc do you mean... Yet - it works just fine. proc min[T](x, y: T): T = if x <

import unicode, strutils: ambiguous call; both unicode.strip and strutils.strip

2021-05-04 Thread masiarek2
Adding "import unicode, strutils" triggers error:/Volumes/T7/Nim/_my_code_ex/template_alias_reference.nim(28, 18) Error: ambiguous call; both unicode.strip(s: string, leading: bool, trailing: bool, runes: openArray[Rune]) [declared in /Volumes/T5/.choosenim/toolchains/nim-1.4.6/lib/pure/unicode

wikipedia: nim reference - regex engines - comparison

2021-05-02 Thread masiarek2
yes, so what should be a correct comment on Wikipedia ?

regex

2021-05-02 Thread masiarek2
whoops - "re" and "regex" are different :-) ... read the manual ... : import regex match "uabyxabyzc", rex"ab.z": echo matches Run

regex

2021-05-02 Thread masiarek2
works fine: import re echo find("uabyxabyzc", re"ab.z") # found pattern "ab.z" at position 5 Run when I flip from re to regex: import regex # <== change "re" to "regex" echo find("uabyxabyzc", re"ab.z") # found pattern "ab.z" at position 5

wikipedia: nim reference - regex engines - comparison

2021-05-02 Thread masiarek2
How I should update wiki page: * Currently the comment is: * Standard library includes PCRE-based re and nre modules, as well as various alternatives (ex. strutils, pegs (Parsing Expression Grammar matching), strsca

learn Nim regular expressions - regex, re , NRE

2021-05-02 Thread masiarek2
@didlybom1h , what languages add regex to the core / stdlib? But I guess even if there are languages do this - the next question is - would it be the right thing to do? I was learning Ruby and Python before - they both must import regex... There is probably a good reason for this behavior.

file - copy Line by line - error

2021-05-01 Thread masiarek2
error:/Volumes/T7/Nim/_my_code_ex/file_copy_by_lines.nim(8, 11) Error: ambiguous call; both io.open(filename: string, mode: FileMode, bufSize: int) [declared in /Volumes/T5/.choosenim/toolchains/nim-1.4.6/lib/system/io.nim(732, 6)] and encodings.open(destEncoding: string, srcEncoding: string) [d

learn Nim regular expressions - regex, re , NRE

2021-05-01 Thread masiarek2
I want to learn regular expressions within Nim. What module should I use: * regex * re * NRE

sorting enum - by identifier and int?

2021-05-01 Thread masiarek2
sorting works with seq: import algorithm type Candidate = enum Candidate_a = "zzz_kast" Candidate_b = "aaa_first last_name" proc enumToStrings(en: typedesc): seq[string] = for x in en: result.add $x var s = enumToStrings(Candid

sorting enum - by identifier and int?

2021-05-01 Thread masiarek2
I love this: type Candidate = enum Candidate_a = "aa" Candidate_b = "first last_name" for i in Candidate: echo i Run

sorting enum - by identifier and int?

2021-05-01 Thread masiarek2
testing max integer in enum: type E = enum Ea = 9223372036854775806. # works fine # Eb = high(int) # fatal.nim(49) sysFatal Error: unhandled exception: over- or underflow [OverflowDefect] Run

sorting enum - by identifier and int?

2021-05-01 Thread masiarek2
THANK YOU

sorting enum - by identifier and int?

2021-05-01 Thread masiarek2
Thank you! Wow, I need to learn 'collect' and 'sequences' to understand what is going on with the proc 'cmpById' :-) However, adding a new member at the end: 'CanC = 5' results with Error: type mismatch: got again. import algorithm,sugar type Candidates = enum Ca

sorting enum - by identifier and int?

2021-05-01 Thread masiarek2
I am learning enum and I wonder if it is possible (does it make sense is a different story) to sort value in enum? import algorithm type Candidates = enum CanB = 2 CanA = 3 echo sorted(Candidates). # Error: type mismatch: got Run I

echo isAlphaAscii("ą") - expecting false (instead of error)

2021-04-28 Thread masiarek2
Python is weakly typed - so it is not a fair comparison - but it is much more forgiving: mystr = "ą" print(mystr.isascii()) # response: false Run What is the risk of taking _both_ types: the string AND the char type and gracefully respond with false if the strin

echo isAlphaAscii("ą") - expecting false (instead of error)

2021-04-28 Thread masiarek2
expecting simple FALSE instead of error: import strutils import std/[unicode, sequtils] echo isAlpha("a") # true - works echo isAlpha("ą") # true - works echo type ("ą") # string echo isAlpha("ą") # true - works echo isAlphaAscii('a') # true - works # e

not-nil-annotation

2021-04-27 Thread masiarek2
I found better documentation at:

not-nil-annotation

2021-04-27 Thread masiarek2
running the example at: results with: Error: undeclared identifier: 'TObj' After adding variable: var TObj = "aa" Run Now I get error: Error: type expected. How to get expected 'not nil' error

char type: echo ASCII code for 'space' and 'single quote'

2021-04-25 Thread masiarek2
Actually single quote works fine: echo '\'' # prints as expected ' echo '\''.repr# prints as expected ''' Run However, how to print ASCII code?

char type: echo ASCII code for 'space' and 'single quote'

2021-04-25 Thread masiarek2
Character type "char": * how to print ASCII code for 'space' * 'single quote' character surrounded by single quotes (it seems to be an exception)? echo '\n'.repr# prints ASCII code 10 (enter) echo ' '.repr # prints ' ' - but how to print ASCII code (space)? e

Incorrect example in documentation for Return statement?

2021-04-23 Thread masiarek2
link: search for proc returnZero(): int = # implicitly returns 0 Run I get error message: Error: invalid indentation 1.4.6/config/nim.cfg' [Conf]

Unicode string print - the four faces look different when printing - why?

2021-04-18 Thread masiarek2
var s = "Hello 👨‍👩‍👧‍👦" echo s Run See the screenshot at:

python: print(x, end=" ")

2021-04-18 Thread masiarek2
wow - both answers are great. THANK YOU!

python: print(x, end=" ")

2021-04-18 Thread masiarek2
Python allows large number of variables to be printed on the same line (without line return) Please compare: var x = "aa" var y = "bb" stdout.write(x, " ", y, "\n") Run # stdout.write(x y z & " ") # error # stdout.write(x, y, z & " ") # error x = "aa

python: print(x, end=" ")

2021-04-18 Thread masiarek2
I am unable to find equivalent in Nim: * python print(x, end=" ") How to achieve sth similar?

string split by {';'}

2021-04-15 Thread masiarek2
I tested a NEGATIVE test case. I was expecting that no split will happen - yet, split does happen unexpectedly ...

string split by {';'}

2021-04-15 Thread masiarek2
include prelude var s = "foo\rbar\cbaz\lend" for e in split(s, {';'}): echo e # output: baz end # expected: "foo\rbar\cbaz\lend"

strformat: using a ':' in a string literal possible?

2021-04-14 Thread masiarek2
I get error: /Volumes/T5/.choosenim/toolchains/nim-1.4.4/lib/core/macros.nim(550, 9) Error: expected: ':', but got: '[EOF]'

nim program name with spaces

2021-04-02 Thread masiarek2
nim program name - is there a limitation? Can I use space in the program name? It seems that I must use underscores in the program name * this fails: 'foo bar.nim' * this works: 'foo_bar.nim' I tried Python - it works: amasa@Adams-iMac /V/T/N/_my_code_ex (master)> python foobar.py A amas

quit() - inconsistent behavior - osx terminal vs visual studio

2021-03-28 Thread masiarek2
> # OSX terminal > > > head n.nim > > quit("bar")⏎ > > > ./n > > bar > # now compare to VS Code IDE: > >> Hint: /Applications/nim-1.4-1.4/bin/n [Exec] bar >> >> Error: execution of an external program failed: >> '/Applications/nim-1.4-1.4/bin/n ' >> >> # I am expecting in both cases the sam

echo () vs echo()

2021-03-21 Thread masiarek2
echo () echo() echo () produces this: () () Is it consistent with SOMETHING? We get two pairs of brackets (first and third). Why the middle one (second) is not producing anything? Why is first producing ().