Array Difference

2021-04-06 Thread miran
> You may have some trouble following this long discussion :-) There's no need for this.

Array Difference

2021-04-06 Thread spip
Is the real problem about discoverability in the documentation? [Difference of two sets](https://nim-lang.org/docs/system.html#-,set%5BT%5D,set%5BT%5D) is already there, though not with `seq`. Do we need to improve the documentation search engine ([CTRL]+[F])? Do we need better or more descrip

Array Difference

2021-04-06 Thread Stefan_Salewski
You may have some trouble following this long discussion :-) Of course set difference is available, but we may need it for arrays and sequences. The plain solution converting the seqs to set, do difference operation and convert back is not always what we want, as we may want to preserve duplica

Array Difference

2021-04-06 Thread Araq
> To play devil's advocate: it's natural to expect isOdd() from a language > which recommends using inc() instead of += 1 As I said, I don't mind isOdd/isEven, I also like `setBit` instead of `|=`.

Array Difference

2021-04-06 Thread Zoom
The highlighting example should be implemented via an `iterator().advance_by(2)`, no check is needed. So only one use-case left :P Rust doesn't have those functions, even though their std is opulent. Someone made the crate for this, don't know, ironically or not. Hope it's not buggy. To play de

Array Difference

2021-04-06 Thread Stefan_Salewski
> That's what I wonder about. I can see odd/even useful for a chessboard and > for highlighting every odd line in a table. And that's it, 2 use cases are > known to me. :-) For me it occurs nearly in each module: When working with trees, like the RTree or a MinMaxHeap actions depend on the fact

Array Difference

2021-04-06 Thread Araq
Python doesn't support `-` on "lists" and Python survives. It's fundamentally an operation on _sets_ and not on seqs anyway. > How can I write it in Nim? And when we point beginners to you two lines code > we simple loose many beginners in early state. And otherwise we lose the same people two

Array Difference

2021-04-06 Thread Araq
> Most of these modules contain somewhere a even/odd decision, and whoever has > used Ruby, misses these functions. That's what I wonder about. I can see odd/even useful for a chessboard and for highlighting every odd line in a table. And that's it, 2 use cases are known to me. :-)

Array Difference

2021-04-06 Thread Stefan_Salewski
Back to the initial topic: let bSet = b.toHashSet() echo a.filter((x) => x notin bSet) Run is a smart solution,and all your mentioned points are true. But in Ruby we can just write seq1 - seq2, and I strongly assume this works also in other high level languages li

Array Difference

2021-04-06 Thread Stefan_Salewski
> why you did it a dozen times already. Because the proc is so tiny that I always was too lazy to put it in one of my own local lib modules, and I thought that it finally would find its way to Nim std lib. And when I needed it again, I was to lazy to search for it in my existing code, so wrote

Array Difference

2021-04-06 Thread juancarlospaco
You can use

Array Difference

2021-04-06 Thread Araq
> So whenever I need even/odd decision, I create an isEven/isOdd proc. I did it > a dozen times in Nim. I don't mind adding isOdd/isEven to math.nim but I do wonder why you did it a dozen times already. What kind of programs do you write? I don't understand. Most programs don't need isEven just

Array Difference

2021-04-06 Thread Stefan_Salewski
Ruby has even() and odd() for sure, I have used Ruby for some years. And I saw isOdd() isEven() in Rust API docs, but I am not sure if that was a extern crate (package). Of course it is an old joke that that some people created packages which contained only the odd()/even() functions. But that

Array Difference

2021-04-06 Thread Stefan_Salewski
Well, google still can not find it, and I just tried, it does not work out of the box when I create a new Nim file and type "echo isOdd(1)". So after some thinking of some of your former post, I get the feeling that it is just your attitude: WE DONT NEED IT again! So let me explain it again, ju

Array Difference

2021-04-06 Thread pietroppeter
as far as I know, python does not have a `is_even` / `is_odd` in stdlib (you can find packages). Not an expert of Rust, but I could not find it in stdlib through google (I did find crates with that). Relevant (serious) link: Relevant (funny) link:

Array Difference

2021-04-06 Thread Stefan_Salewski
At least isOdd() and isEven() does not appear when I type that function names into the search box at So where should they hide?

Array Difference

2021-04-06 Thread miran
> Unfortunately Nim lacks still a lot of functions available in other > languages, starting with the plain isOdd() and isEven() for numeric variables. Either my calendar is wrong, or your April's fools joke is several days late.

Array Difference

2021-04-06 Thread Zoom
Don't think this `-` is a good candidate for std. 1. It silently draws sets in deps. 2. For "algorithms which work a lot with differences" it's probably better to keep the sets around, not recreate them on each operation. 3. The `-` name is ambiguous, it's ok for sets, but for arrays explic

Array Difference

2021-04-06 Thread Stefan_Salewski
> \- would be a good name candidate Unfortunately not really. You may have missed the & story many years ago :-) Araq used & instead of + for seq concatenation. One of his motivation was that he later might use + as "[1, 2] + [3, 4]" resulting in [4, 6]. The other reason may be that array conca

Array Difference

2021-04-06 Thread lqdev
Not as far as I know. I think if we would add such a proc to the standard library, `-` would be a good name candidate as we already use normal operators `+`, `-`, `*` for sets, instead of ∪, ∖, ∩.

Array Difference

2021-04-05 Thread Stefan_Salewski
Yesterday i was not able to find a proc for the array difference known from other languages like Ruby. I think I was searching for it already five years ago when I was new to Nim. It is available maybe with a different name already? As we use & for concatenation of sequences, using `-`