Thanks, that worked.
An example:
MyExample = object
field: name
my_examples: seq[MyExample]
proc updateMyExample(old_name: string,
new_name: string,
my_example: var MyExample) =
if my_example.field == old_name:
my_
`for my_example_i in my_example.my_examples.mitems: `
Run
I try to write a handler for an `input type="file"` HTML5 element in Nim.
In the HTML I have a Upload button defined as
Run
and I set the button's `onchange` handler to a `changed_file` function, which I
define in Nim as
proc changed_file (event: Event)
Ok, here a small example of my "tasks" setup for Nim as I use it at the moment.
This is probably not the best way to do these things but it is the result of
how I understand NimScript:
A minimal `config.nims` looks like this:
#
# NimScript build file for Project X
#
Here's an example type that uses a tree structure:
ExampleType* = object
name*: string
example_types: seq[ExampleType]
Run
However, if I'm iterating through the tree, how do I update a field?, E.g.:
proc changeField*(example_type: var ExampleTy
`for i in example_type.example_types` does `.items` you want do
`example_type.example_types.mitems` which returns a mutable view to the values.
I totally agree that stacking is very important to render many of the world's
languages. And it will be a slog to get to 99.% support. Eventually I will
figure all of that out. But I am already happy-that I support ~99.98% of
world's online users with just Alphabets + CJK in my demographic a
Hello,
Thank you for your valuable comment and code.
It looks like I made a change that battery is created in ElectricCar
constructor without separate Battery constructor (which indeed was in the book
:)), but as the author said - One day you should consider would you use battery
on its own or
My Nim is **very** rusty then ;-). Thanks, that was an easy fix.
> I would be interested to know what are other users that would be interested
> in maintaining such a library.
Me, for a generic geometry library using different kernel (float, fixed-point,
rational, decimal).
i think i'm looking at a different edition,(pg 174 for me) but the point of the
exercise is adding a separate Battery object to the ElectricCar once there get
too many battery-related variables, and it makes use of default parameters when
initializing the Battery.
so, perhaps nitpicking here, b
Thank you. This idea also showed in my mind… but I wanted to reflect python
code from the book as much as possible. Anyway solution worth knowing.
You could also do something like this, defining a type alias for battery size.
Or `BatterySize = distinct int` if you want a type `BatterySize` that is
distinct from any other int but still uses an int data type. That means you
need to initialize 70 as `70.BatterySize` though, or create a `conve
Thank you for your example. Don't know much about what's happening there, but
I'll investigate it. And yeah, Can't wait to learn templates and macros.
I recently started my first open-source project for a lightweight UI helper :)
Basically, it is just a wrapper for Webview and Jester with some additional
helper tools.
The goal was to create something that simplifies creation of offline (desktop)
applications based on HTML/CSS/JS on MS-Windows
> Async way is not the only way to create event based systems.
Of course it isn't. But it works well in Erlang thanks to many other aspects
("crash-only" error handling style, supervision trees, supercheap threads,
message passing and matching). Some of these are less useful for e.g. GUI -- at
I just spotted it myself! Jesus.
This is the correct one:
let sorted: ValueArray = x.a.sorted(
proc (v1, v2: Value): int =
cmp(v1.d[aBy.s], v2.d[aBy.s]), order=order)
Run
I was using `(Value,Value)` (a tuple) for the custom cmp proc. And whil
Hello,
I am currently testing using `zig cc` as a `c` compiler for some of my `nim`
projects, and it's working flawlessly with the `envcc` compiler option. The
only thing I can't figure out is how to set the `buildLib` command to build
static libraries.
Ideally, I'd like to have the same comma
did you export `d`? `d*: OrderedTable[...]` (note the asterisk)
So, the scenario is this:
I have an array (`ValueArray`) of `Value`s. (which is a `ref object` with a `d`
_OrderedTable_ field).
Long story short, I want to sort this array of Values by dictionary key.
So... this is what I've done:
let sorted: ValueArray = x.a.sorted(
p
Yes, of course. The `Value` objects (and their fields) are being used in
hundreds of different places across the project.
For some reason, it's inside the custom `cmp` proc that they're not recognized.
P.S. In case it matters, the code in question is inside a _template_.
22 matches
Mail list logo