Re: Nim on Android

2017-11-23 Thread hawk_king
Yes true, please try this: pkg update pkg install libandroid-glob-dev libandroid-glob git clang nodejs pcre pcre-dev libsqlite git clone https://github.com/nim-lang/Nim cd Nim git clone --depth 1 https://github.com/nim-lang/csources cd csources find ./ -

Re: Question about sockets

2017-11-23 Thread dawkot
Thanks, weird that I missed recvFrom when looking through the library.

Re: Packed Strings, how to pack fixed length number of chars in an struct.

2017-11-23 Thread treeform
Araq helped me with this, turns out you need static[int] to get around "Error: cannot instantiate" This works: type PackedString[N: static[int]] = array[N, char] proc pack[N](str: string): PackedString[N] = if str.len > result.len: raise newException(Va

Packed Strings, how to pack fixed length number of chars in an struct.

2017-11-23 Thread treeform
I am trying to get some thing like this to work, but I am having issues with arrays and the type system: Working code, but I have to write array[16, char] which is awkward: proc pack[A](str: string): A = if str.len > result.len: raise newException(ValueError, "Can't p

Re: Looking for a set that sorts and deduplicates

2017-11-23 Thread cblake
@Araq - fabulous. I think a B-Tree in the stdlib would be great. @mratsim - I think you meant `collections.intsets` with a 't' which does _not_ yield items() in key order. The built-in `set[up to int16]` type _does_ (implicitly) order its keys, though. @cdome also did not mention how large the

An orientation document to the "mainstream" developer

2017-11-23 Thread kobi
Hello all, I wrote a document to quickly introduce nim to developers from mainstream languages like c# or java. (basically it sums what I understood about the language.) For an experienced programmer, this is faster than reading a technical manual. A quick-glance skeleton with bullet points to

Re: Pointer to generic type with unspecified generic parameter?

2017-11-23 Thread monster
I totally missed that. I thought you could only inherite when you want "dynamic dispatch"(ref object of RootObj)!

Re: Question about sockets

2017-11-23 Thread euant
Yep, see the following example: import net let listener = newSocket(sockType=SOCK_DGRAM, protocol=IPPROTO_UDP) # listen on port listener.bindAddr(Port()) var data = newString(1024) # receive buffer of 1024 bytes senderAddress: string

Re: Copy-on-write container

2017-11-23 Thread mratsim
@Udiknedormin: Actually `map` is the easiest, you can just do: for i in 0||(container.len - 1): result[i] = mapped_op(container[i]) OpenMP will divide work statically in `(container.len - 1) / threads_count` chunks. Right now Arraymancer offers 2 choices, value and ref s

Re: Looking for a set that sorts and deduplicates

2017-11-23 Thread mratsim
`insets` dedups for sure and seems extremely fast. I don't know if it's items is sorted though.

Re: Looking for a set that sorts and deduplicates

2017-11-23 Thread Araq
I have a B-Tree implementation. Remind me to release it.

Re: Looking for a set that sorts and deduplicates

2017-11-23 Thread cblake
`CountTable` is just a histogram and the sorting is by the bin counts not by the keys. Keys are visited in "hash order". `hashes` does use an identity hash for integers which could create some confusion from a simple test program if the modulo the table size post hash transform doesn't change th

Re: Looking for a set that sorts and deduplicates

2017-11-23 Thread jlp765
`CountTable` from the `tables` library can also do this. I don't know how it compares speed-wise with the previous solution The `keys()` iterator will retrieve the sorted numbers (it sorts on insert??), and the value is the number of occurrences. If you already have a sequence of data, you can

Question about sockets

2017-11-23 Thread dawkot
Is it possible to get the source address of a received UDP packet using the net library?

Re: What's wrong with this simple macro?

2017-11-23 Thread dawkot
Ok, thanks.

Re: Pointer to generic type with unspecified generic parameter?

2017-11-23 Thread Udiknedormin
@monster Why not use inheritance? type ThreadID* = distinct uint8 AnyMsg = object {.inheritable.} sender*: ThreadID receiver*: ThreadID previous: ptr[AnyMsg] Msg*[T] = object of AnyMsg content*: T let space = all