How to make an object mutable in recursion?

2021-03-08 Thread jasonfi
Thanks, that worked.

How to make an object mutable in recursion?

2021-03-08 Thread jasonfi
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_

How to make an object mutable in recursion?

2021-03-08 Thread xigoi
`for my_example_i in my_example.my_examples.mitems: ` Run

JS backend: How to access the `files` attribute in the Node object of an `input type="file"` element

2021-03-08 Thread halloleo
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)

Yeay! Finally I udnerstand how to write a "Makefile" in Nim!

2021-03-08 Thread halloleo
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 #

How to change an object's field, in a complex object, when using recursion?

2021-03-08 Thread jasonfi
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

How to change an object's field, in a complex object, when using recursion?

2021-03-08 Thread ElegantBeef
`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.

Typography update - now it can render 99% the Google Fonts ttf.

2021-03-08 Thread treeform
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

How to embed objects in another objects

2021-03-08 Thread SebastianM
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

array, seq : is there something in between?

2021-03-08 Thread bpr
My Nim is **very** rusty then ;-). Thanks, that was an easy fix.

Why not introduce the concept of Decimal in nim ???

2021-03-08 Thread lbart
> 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).

How to embed objects in another objects

2021-03-08 Thread shirleyquirk
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

How to embed objects in another objects

2021-03-08 Thread SebastianM
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.

How to embed objects in another objects

2021-03-08 Thread PMunch
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

How to embed objects in another objects

2021-03-08 Thread SebastianM
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.

Nimview - a lightweight UI helper

2021-03-08 Thread marcomq
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

Channel / Actors based parallelism? Are there such Web Servers?

2021-03-08 Thread cumulonimbus
> 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

Sorting array by object key

2021-03-08 Thread drkameleon
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

Add "buildLib" option to "envcc"

2021-03-08 Thread vitreo12
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

Sorting array by object key

2021-03-08 Thread aEverr
did you export `d`? `d*: OrderedTable[...]` (note the asterisk)

Sorting array by object key

2021-03-08 Thread drkameleon
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

Sorting array by object key

2021-03-08 Thread drkameleon
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_.