This indirection is required because event handlers in Karax need to have the
type proc () or proc (ev: Event; n: VNode).
addEventHandler(tmp3, EventKind.onclick,
() => lines.add "Hello simulated universe", kxi)
these two ways found in readme, I dont using karax , doest know if there is dom
Thanks a ton @Yardanico and @bung, this solved a lot of trouble. I also looked
at the nim forum source but didn't understand why they were using the
dom.document api instead of karax's own vdom, but as @Yardanico pointed I was
thinking I'm manipulating the dom.
Altought it's still not
by using karax the way you got value from vnode through data binding , get
value from state or event.
or using traditional web technic document.getElementById(xxx).value or
addEventListener
Well I debugged it a bit and seems like .value for both nodes is empty (nodes
themselves are found without issues). And skimming through the code of Karax I
don't think that this is the right way to get a value of an input, all input
examples in Karax seem to use custom event handlers or set
Nim and static type noob here. So the problem is when I compile my code and run
it in browser, fill the name and description fields and click add thing button,
my browser console gives following cryptic runtime errors:
TypeError: c_225079 is null quicktest.js:579:16
keys is an iterator so either iterate over it with a for loop or use toSeq from
the sequtils module
I have this object structure:
type Item* = ref object
path*: string
tags*: seq[string]
type DB* = object
data*: Data
items*: OrderedTable[string, Item]
var db*: DB
var original_jtext: string
Run
I parse some json with:
The `cnt +=` operation in parallel is ripe for creating a `reduction` like
option for Nim that's in `OpenMP`.
[https://stackoverflow.com/questions/13290245/reduction-with-openmp#13290673](https://stackoverflow.com/questions/13290245/reduction-with-openmp#13290673)
OK, I had to clean it up a little to make it work, but here is the code that
gets it to compile.
var cnt: array[rescnt, uint]
parallel:
for i in 0..rescnt-1:
cnt[i] = spawn segcount(i*KB, Kn)
sync()
for i in 0..rescnt-1:
primecnt +=
try
var cnt = array[rescnt, int]
parallel:
for i in 0..rescnt-1:
cnt[i] = spawn segcount(i*KB, Kn)
sync()
for i in 0..rescnt-1:
primecnt += cnt[i].uint
The error messages keep saying the issue is a mismatch with FlowVar[T]. In
Chapter 6 of **Nim in Action** here is what it says they are.
`FlowVar[T] can be thought of as a container similar to the Future[T] type,
which you used in chapter 3. At first, the container has nothing inside it.
When
Why do you refuse to try
cnt[i]
as jlp765 suggests?
Do you have an idea how plain
cnt +=
should work? All the parallel calculated results should accumulate in this
single variable. Then you may need something to control the access to it.
In the previous snippet I forgot the `spawn`. The code below compiles, but is
slower.
var cnt = 0# count for the primes, the '1' bytes
for i in 0..
Try
for i in 0..rescnt-1:
cnt[i] = spawn segcount(i*KB, Kn)
I think the issue is with `..<`
Now in your code there is no spawn at all!
For parallel processing, you have to ensure that there are no conflicts when
parallel tasks are accessing your data, otherwise the compiler may make copies
of the data before, which may make it slow. And for parallel processing a good
use of the CPU
After reading the **Nim in Action** book I got it to compile by placing a `^`
before `spawn`, but it makes the program slower. The problem has to do with
`segcount` returning a `FlowVar[T]` mismatch. And when I use `parallel:` it
won't compile, and shows even more errors. Doing more research.
I think we will not be able to compile your code, as it looks not like a
complete program.
Do you really expect that
cnt += spawn segcount(i*KB, Kn)
may work? I have no idea how it could.
Maybe what you intent is something like
parallel:
var cnt =
I've done it both with/out `parallel:` as shown below, but get the same
compiler output.
parallel:
var cnt = 0 # count for the segment primes '1'
bytes
for i in 0..
Do you use the parallel statement at all as described in the manual? Or only a
plain spawn? See
[https://nim-lang.org/docs/manual.html#parallel-spawn](https://nim-lang.org/docs/manual.html#parallel-spawn)
You may also need a FlowVar.
I did test parallel once for calculation of a convex hull,
OK, I've racked my brain enough and need help. Using 0.17.2 on Linux, I have
this `proc` below.
proc segcount(row, Kn: int): int =
var cnt = 0
for k in 0..
20 matches
Mail list logo