Could you post your Python source code too? Often when people post these kinds
of comparisons, their programs are doing slightly different things.
It also feels like CountTable is better choice for your problem.
[https://nim-lang.org/docs/tables.html#CountTable](https://nim-lang.org/docs/tables.html#CountTable)
Is that correct?
type
StringSlice
src: ptr string
a,b: int
Gives me a compilation error! Is it instead:
type
StringSlice = object
src: ptr string
a,b: int
Also how can I use this with the type Table:
you can also add all c files of raylib manually with the compile pragma, like I
did it in AntTweakBar
[https://github.com/krux02/nimAntTweakBar/blob/master/AntTweakBar.nim#L43](https://github.com/krux02/nimAntTweakBar/blob/master/AntTweakBar.nim#L43)
well you can create your own StringSlice type that does not copy and override
the slicing:
type
StringSlice
src: ptr string
a,b: int
proc `$`(arg: StringSlice): string =
(arg.src[])[arg.a .. arg.b]
well importing in a local block/function has nothing to do with runtime
importing. Just see scala import.
[https://en.wikibooks.org/wiki/Scala/Import](https://en.wikibooks.org/wiki/Scala/Import)
and yes for your case use a when clause. The content of a when brach is at top
level it does not
As @stisa mentioned above, runtime imports are not really possible in Nim
because Nim is not an interpreted language. Runtime imports are possible in a
language like Python because the CPython VM can stop execution in a scope to
import a module. Nim, however, pulls in modules at compile time.
Hello, I was testing a simple stream algorithm with a slice window, but
performance is a bit disappointing! A python 3 version is actually in average
2x faster than the nim version.
My code:
import tables, times
const WORD_SIZE = 4
const K = 1
iterator
En orecchini a cuore guess outre, accessoires de granulés plus guess nouvelle
collection. La première zone et bagues guess fournit plus de plus de plus de
250 points de vente pour tous: maman. Résoudre le sac guess en solde problème
en lui achetant son propre les quelques boucle d'oreille guess
your example works and my example also works.
Last week I switched to Xonsh and this was the problem, it works when I run
env SHELL=/bin/bash gdb hello
thanks
Well you use `dynlib: LIB_RAYLIB` (which is fine) and add linker commands
`{.passL: "-L. -lraylib".}` at the same time! That's wrong! Use one way or the
other, preferably the `dynlib` solution.
proc rand*(maxval: uint32): uint32 =
let limit = uint32(high(uint32)) - uint32(high(uint32)) mod maxval
var bits = rand_u32()
while bits > limit:
bits = rand_u32()
result = bits mod maxval
Looks suspicious. high - high is 0, isn't it? And there are MUCH
No, but you can use `--dynlibOverride:libname` and some
`passL:llibabsurdnaming.so`
Thanks for the replies!
No I have been using nim-0.17.0 so far. But nice to see that this is a fixable
thing. I'll look into that later today.
Edit// @bluenote I added your fix now, and the result looks much more random.
Thanks for that!
For 1, if the condition is available at compile time (generally this means
`abc` and `def` are `const`) you can use a `when` block to import the module,
eg:
when cond:
import foo # this is only imported if `cond` is true and evaluable at
compile time
if cond:
Hi, I'm using a wrapper from "unofficial packages" that was set up to use a
dynamic library. If I want to link to a static version of the library, would it
be as easy as find/replace "dynlib: LibName" with "header: "LibName.h"?
I'm trying to get some Nim bindings for [this neat little game programming
library called raylib](https://github.com/raysan5/raylib/). But well, I'm
having some difficulties trying to do so.
After cleaning up raylib.h, I was able to use c2nim to auto-generate a .nim. I
commented out a few
17 matches
Mail list logo