Hi,
I'm having problems following the examples. What I'm trying to replicate is count from here: https://nim-lang.org/docs/sequtils.html#count%2CopenArray%5BT%5D%2CT
My code is as follows and I have nothing else in the file (direct copy from the website with imports from the top of the page):
import macros, strutils
let
s = @[1, 2, 2, 3, 2, 4, 2]
c = count(s, 2)
assert c == 4
The error I'm getting is as follows:
.nim(5, 12) Error: type mismatch: got <seq[int], int literal(2)>
but expected one of:
proc count(s: string; subs: set[char]): int
first type mismatch at position: 1
required type: string
but expression 's' is of type: seq[int]
proc count(s: string; sub: char): int
first type mismatch at position: 1
required type: string
but expression 's' is of type: seq[int]
proc count(s: string; sub: string; overlapping: bool = false): int
first type mismatch at position: 1
required type: string
but expression 's' is of type: seq[int]
expression: count(s, 2)
Filename is hello.nim and the command i'm using in terminal is "nim c -r hello.nim". I'm in Arch linux.
What I'm doing wrong? I guess my biggest question is that I'm copying that directly from the examples and it's giving me errors. I think the examples should give a newbie like me a working starting point :)