7 ms·
With many languages adopting LINQ object querying, I find it more and more suitable to start using math's set operators for them. Many languages have almost ide
by sharpercoder 8y ago
With many languages adopting LINQ object querying, I find it more and more suitable to start using math's set operators for them. Many languages have almost identical behavioral sequence operators (.find in js, .Where in C#, etc) but math sort-of standardizes them all with a sound theoretical background. I'm not entirely sure if they all map 1-to-1, but at least most will.
const items = ∅; // empty set
if (myItem ∈ items) { ... } // is element of
const union = items ∪ otherSet;
assert items ≌ ∅; // items are all equal
- tomsmeding 8y agoWhat exactly do you mean by "items ≌ ∅"? The only thing I read in that is "is isomorphic to the empty set", which with all reasonable definitions of isomorphic is the same as that 'items' is empty, which isn't the same as "items are all equal".
- sharpercoder 8y agoAll items are equal to the second sequence. Which means, no items in "items". I could have picked a better example :P
- garmaine 8y agoYou should read Date and Darwin’s The Third Manifesto.
- pvg 8y agoThis a great example of how 'naming things' is by far and away the hardest problem in computer science. If you're going to call something 'normal form' or 'manifesto' it's best if there's exactly one of them. By the third one, others start wondering how normal the first form could have been and whether it might not have been more prudent to try a communique or memorandum before going full manifesto.
- garmaine 8y agoWhile I understand your point, it is my understanding that the first two "manifestos" weren't by Date and Darwin. I think Cobb's original article introducing the very idea of the relational model is one of them, and I forget the other. They are rather making an egotistical (but IMHO deserved) point that their work is the 3rd revolutionary call to action in the history of relational database systems.
- pvg 8y agoYes, it's not entirely without uses to have a third manifesto. There was, for instance, a NoSQL manifesto a few years ago. Relational purists could reasonably point out this is a clear sign of the immaturity of the new technology as they were on their third manifesto nearly two decades previously.
- tabtab 8y agoI found some of those purists very annoying. The real world is often messy and organic, and trying to force excessive order on it just makes for confusion and/or silly extra busy-work.
- klmr 8y agoThe computer science formalisation of these operations is known as “relational algebra”, which is based on set algebra. That said, the assertion that all elements in a set be equal doesn’t really make sense — or rather, it’d be written as “|S| < 2” by virtue of the fact that a set is defined as containing distinct elements; consequently, in a set with more than one element, all elements are not equal. If you want to use mathematical formalisms for set operations, you’d instead have to work on sets of tuples and test for a predicate: “∀x ∈ S: p(x)”.
- pjmlp 8y agoMost people might only have learned LINQ via its successful introduction in .NET and the work Erik Meyer and his team did. However most of the LINQ features using the plain method call API were already exposed in Smalltalk collections. object.Where(cond).Select(something) would be (object select [ :element | cond ]) collect: [ :element | element ]
- deleted 8y ago[deleted]
- b34r 8y agoTyping these characters is quite annoying though. The characters for most programming languages are readily visible on a 108 key keyboard, which means they’re easy to remember and teach.
- Jtsummers 8y agoIn Emacs and other editors you can use a special prefix symbol (typically they use \ like TeX) and substitute the special symbol for the word. \in => ∈ \emptyset => ∅ This allows the user to type in using an input mode they're familiar with (standard text), but get an output that looks better (IMO).
- guidoism 8y agoIt's depressing that this is such a common argument against moving away from the ASCII character set. We all use operating systems that allow us to define key sequences for these characters. And it's really easy to remember them after a week or so, I mean, how often do you actually look at the letters on your keyboard anyways? The main issue is that computers don't come with a standard default layer for math and APL characters anymore so it's a huge leap of faith for someone to start to use these characters.
- posterboy 8y agoI had to paint my keyboard blank to learn writing withot looking at the printed on symbols ...
- untangle 8y ago> Typing these characters is quite annoying though This depends on the implementation. In Dyalog APL for example, the special characters (glyphs) are effected using fairly simple two-key sequences. Mnemonics are used to help learning. I found it fairly straightforward, surprisingly so.
- untangle 8y agoThese constructs map fairly literally into APL.