Array concatenation

2023-01-05 Thread jrfondren
The code in the OP works as-is. What doesn't work?

Array concatenation

2023-01-05 Thread Hlaaftana
The real reason is generics don't work like the code sample above for arrays, instead they have a range type, possibly an enum as the first type and this would have to be ignored in any implementation in favor of `0 ..< a.len + b.len`

A seasoned programmer's take on Nim's docs

2023-01-05 Thread jtv
Coming onto a project that already exists is a lot different than selecting a language for whatever new ยต-service is needed today. Nobody wants you to rewrite the code that is already there, but I have seen inside a large number of tech companies, and can tell you that, in 'big tech', language c

A seasoned programmer's take on Nim's docs

2023-01-05 Thread carterza
> In my experience, decisions on > language choice in most of the big > > tech companies are generally bottoms up. The company often won't have any > oversight on language choice. I've seen people in big tech companies consider > not going with Rust because they were worried about the size o

Array concatenation

2023-01-05 Thread ElegantBeef
I'd say the main reason is in most uses of array concatenation it can be statically folded into a constant so there isn't much difference between seq and array concatenation. Though it'd be nice to have in the stdlib an easy way to concatenate arrays.

Array concatenation

2023-01-05 Thread japplegame
> Because & is only for string concatenation in Nim. and sequences

Array concatenation

2023-01-05 Thread PMunch
Because `&` is only for string concatenation in Nim. You can use `concat` to concatenate arrays

Array concatenation

2023-01-05 Thread japplegame
> You can use concat to concatenate arrays. Which file should I import for `concat'? Looks like `concat` from `std/sequtils` cannot concatenate arrays, only sequences.

Array concatenation

2023-01-05 Thread japplegame
Why is the `&` operator not defined for arrays? Is this intentional? proc `&`[T; al, bl: static[int]](a: array[al, T], b: array[bl, T]): array[al + bl, T] = for i, e in a: result[i] = e for i, e in b: result[i + al] = e Run

Nim v2: what would you change?

2023-01-05 Thread Hlaaftana
If you just want object fields, you don't need extra indentation, you can use something like: template a: untyped = self.a Run And you can have a macro that generates these automatically on the same indentation level.

Is there a way to print the documents without printing the rest of the html?

2023-01-05 Thread geotre
Assuming there's no existing mechanism to generate it, here's a workaround: Install a browser extension like Stylus ([chrome](https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne/related), [firefox](https://addons.mozilla.org/en-GB/firefox/addon/styl-us/)) that allo

A seasoned programmer's take on Nim's docs

2023-01-05 Thread jtv
Thanks, thoughts below. > trying to be synthetic, but I have enjoyed the exchange, there is material to > untangle in multiple threads here. :) > on concepts: looking forward to your > write up! > on compiler errors: yep, they can get bad, with some experience > they become better to navigate,

Is there a way to print the documents without printing the rest of the html?

2023-01-05 Thread grd
Suppose that I want to print On the left side you see all the links, but the only thing that I want to print is the text on the right. Is there a way to print it?

nimqt - bindings to Qt

2023-01-05 Thread grd
Yes, you did great work. I admire that.

nimqt - bindings to Qt

2023-01-05 Thread jerous
Not interested in wrapping other widgets that I'm not going to use. I developed nimqt just for my own little projects

Is there a way to print the documents without printing the rest of the html?

2023-01-05 Thread pp
Please, could you specify better what you want to achieve?

A seasoned programmer's take on Nim's docs

2023-01-05 Thread pietroppeter
trying to be synthetic, but I have enjoyed the exchange, there is material to untangle in multiple threads here. :) * on concepts: looking forward to your write up! * on compiler errors: yep, they can get bad, with some experience they become better to navigate, still could definitely be an

NimForUE

2023-01-05 Thread jmgomez
Hey guys, here is a video on getting started on Windows. [https://www.youtube.com/watch?v=NuB_PjxVisw&ab_channel=JuanMG%C3%B3mez](https://www.youtube.com/watch?v=NuB_PjxVisw&ab_channel=JuanMG%C3%B3mez) Hopefully the audio is better than the NimConf recording Let me know if you try it out and ha

Is there a way to print the documents without printing the rest of the html?

2023-01-05 Thread grd
I want to print some of the libraries.

Two type matches, both wrong: how to do it right?

2023-01-05 Thread koistinen
This is getting to much like the complications of Java or C++. Maybe it is better to skip Square and Bitboard types and just use uint8 and uint64 instead or have them as aliases. I want the code to be readable, not have many lines that make the code harder to understand in most circumstances.

Nim v2: what would you change?

2023-01-05 Thread RodSteward
I would like to have the {.this: self.} pragma back or something similar. NOT something like 'with' that causes an extra indentation. The reason is that I'm tired of writing self, self, self all the time in functions where first parameter is usually the object that you operate on.

Nim v2: what would you change?

2023-01-05 Thread vngantk
Any possibility of making Nim non-indentation based? I have been evaluating Nim for a while, and so far quite impressed with it. One of the things I don't like about Nim is its Python-style indentation. Why can't Nim provide a keyword called "end" (like Ruby) to indicate the end of a block?

Two type matches, both wrong: how to do it right?

2023-01-05 Thread planetis
Definitely make both of them distincts. The `.borrow` pragma will help you avoid some of those casts. I would remove range from the Square type altogether, but maybe keep it in addPiece's sq parameter.

Two type matches, both wrong: how to do it right?

2023-01-05 Thread koistinen
Maybe not doing the overloading of the $ function and instead using a separate functions like Bitboard2string and Square2string is easier?

Delete items in a seq while iterating over it?

2023-01-05 Thread Araq
I always use @doofenstein's solution.

nimqt - bindings to Qt

2023-01-05 Thread grd
I tried and no. It doesn't work. I am gonna make a github issue. It appears to look into historical data. Btw, are you also interested in porting this?

Two type matches, both wrong: how to do it right?

2023-01-05 Thread koistinen
Thanks shirleyquirk! Without Bitboard declared distinct, a silly error I get is it is printed as a Bitboard. Adding in the procs I want to use looks like a good enough solution.

Two type matches, both wrong: how to do it right?

2023-01-05 Thread shirleyquirk
I would declare Square as `distinct` that's enough to get it to compile, but you could declare BitBoard distinct as well, it might save you from some silly bugs in the future. type Square* = distinct range[0..63] proc square*(file, rank: int):Square = (rank*8+file).Square pr

Two type matches, both wrong: how to do it right?

2023-01-05 Thread koistinen
My question: In proc $(p: Position); string I want to get p.game50 as a decimal string representing the integer. Problem is I have specialized conversions to string for the two types Square and Bitboard which are both a kind of integer. What is the right way to solve the problem? c

Regex error - "Error: missing closing ' for character literal"

2023-01-05 Thread shirleyquirk
Thanks that makes perfect sense

Regex error - "Error: missing closing ' for character literal"

2023-01-05 Thread xigoi
Well, how else would you want to escape quotes in raw string literals? Not with a backslash, since the entire point of raw string literals is that you don't need to escape backslashes.

The state of GPU codegen with Nim (bonus: LLVM JIT codegen)

2023-01-05 Thread mratsim
> It'd be great to be able to do GPU / NN stuff in Nim (again). Unfortunately for the time being my focus is cryptography. For GPU / NN, I think Flambeau is the better bet. It will have a side-effect of solving Cuda/OpenCL/Vulkan codegen via LLVM but the kernels still would have to be (re-)impl

Delete items in a seq while iterating over it?

2023-01-05 Thread Zoom
It's probably best to iterate in reverse and use `del`, this way you don't need to double check the condition on the same index after the swap. ## Retains elements of a sequence specified by the predicate. ## Does not preserve order! proc retain[T](s: var seq[T]; pred: proc(x

Delete items in a seq while iterating over it?

2023-01-05 Thread doofenstein
what I usually do is something like this: var i = 0 while i < myseq.len: if deleteCond: myseq.del i else: i += 1 Run it also works with both delete and del, but is admitedly not that pretty.

Regex error - "Error: missing closing ' for character literal"

2023-01-05 Thread shirleyquirk
Where did this design for character escaping via doubling come from? It violates the principle of least surprise, what benefit does it provide?

Delete items in a seq while iterating over it?

2023-01-05 Thread pietroppeter
TIL del vs delete:

A seasoned programmer's take on Nim's docs

2023-01-05 Thread 0x0000ffguy
I agree with you @jtv: having a rich and mature ecosystem lower the entry barrier for newcomers and attract projects to use the language. A strong selling point for Nim, in my case, is the C++ FFI capabilities of the language.