Re: How to implement a dynamic array

2017-06-11 Thread jackpboy
I'm still on chapter 1. It's pretty big. I was trying to write all examples he gave and in his implementation of Stack he does that. So I'll follow your advice and just use seq. Thanks all of you!

Re: How to implement a dynamic array

2017-06-11 Thread Stefan_Salewski
> In Java I just create an array with a certain size and when it's full I > create another one with double the size and copy the elements to it. Of course you can do exactly the same with Nim: You can create a seq of some initial size, fill in elements, create a larger one and copy elements

Re: How to implement a dynamic array

2017-06-11 Thread jackpboy
The book is Algorithms from Sedgewick. In Java I just create an array with a certain size and when it's full I create another one with double the size and copy the elements to it. I'm doing it wrong? I'm just following the book. In Nim I couldn't do it. I looked at the source code on github

Nim Koans?

2017-06-11 Thread scriptkiddy
I was looking around for Nim koans to get a little bit of practice. I found this repo: [https://github.com/yashaka/nim_koans](https://github.com/yashaka/nim_koans) Unfortunately, it seems a bit outdated as the last commits are from 2 years ago. I also noticed that it seems somewhat incomplete.

Re: How to implement a dynamic array

2017-06-11 Thread Stefan_Salewski
> I got a Data Structures book Which book do you have? Do you like it? > I know how to do it with Java Can you show us your code? I would like to learn how to do it in Java. Basically, what you need to build something like Nim's seq is allocating chunks of memory from the OS. You may inspect

Re: How to implement a dynamic array

2017-06-11 Thread scriptkiddy
You could always take a look at the Nim source code and see how Nim implements the `seq` data type.

How to implement a dynamic array

2017-06-11 Thread jackpboy
Hi, I'm trying to teach myself programming. I already know Javascript and a little bit of Java. I got a Data Structures book and I decided to follow it and do the exercises with Nim. One of the first exercises is about implementing a dynamic vector, I know how to do it with Java but I couldn't

Re: Nim 0.17.0: template with untyped argument resulting in undeclared identifier

2017-06-11 Thread martincohen
**Araq:** Oh yes, makes sense I worked around it exactly as you have suggested. It would probably make sense if I post this to Nim's issues as well.

Nim 0.17.0: template with untyped argument resulting in undeclared identifier

2017-06-11 Thread martincohen
Hello awesome people, I'm a newbie to Nim, and trying to rewrite my game engine to it to learn. I've encountered a strange problem with template and untyped argument. I'm not sure what exactly is going on. It feels like compiler error really, as the two examples bellow are only different on

Re: How To - Proper Interfacing In Nim

2017-06-11 Thread pwernersbach
**@ivanitto**: I agree with Varriount that it's best to declare the types in Nim along with the correct C type pragmas. You don't have to define the entire type, just enough to indicate its semantics to Nim and to identify it in the C type system: type BoxOfStuff {.final,