News for hackers. Stuff that matters.
Re:Zero One Infinity Rule by Kim_Bruning on Saturday March 18, 2023 @03:11PM (#35212149)
Am I the only person who sometimes makes an exception for "two" ?
Re:Zero One Infinity Rule by jerf on Saturday March 18, 2023 @03:55PM (#35212513)
No.

But I have the decency to feel bad and leave an apologetic comment.

Re:Zero One Infinity Rule by adhesive_wombat on Saturday March 18, 2023 @04:13PM (#35212682)
A ping-pong buffer certainly seems like generalising to a ping-pong-pang-peng-pung-p(infinity)ng buffer would be overkill.
Re:Zero One Infinity Rule by hprotagonist on Saturday March 18, 2023 @04:17PM (#35212704)
i fairly regularly want pairwise, yep.
Re:Zero One Infinity Rule by grensley on Saturday March 18, 2023 @04:27PM (#35212796)
Two is quite relevant for relationships
Re:Zero One Infinity Rule by ChickeNES on Saturday March 18, 2023 @05:58PM (#35213498)
Well, if you ignore polyamory and polygamy...
Re:Zero One Infinity Rule by layer8 on Saturday March 18, 2023 @05:59PM (#35213512)
You can have n-ary relationships. Relational databases are built on that.
Re:Zero One Infinity Rule by grensley on Saturday March 18, 2023 @09:17PM (#35214970)
What are the columns in a relational table like that?
Re:Zero One Infinity Rule by layer8 on Saturday March 18, 2023 @09:20PM (#35214987)
Not sure what you mean. A table with N columns corresponds to an N-ary relation. The rows contained in the table are the tuples contained in the relation. Table = relation. That's why it's called a relational database.

See also this example in Wikipedia of a ternary relation: https://en.wikipedia.org/wiki/Finitary_relation#Example

Another example: If you have a table (SSN, Name, DateOfBirth), then that corresponds to the relation "person with SSN x has name y and date of birth z". In that case it's a relation between SSNs, names, and dates.

Re:Zero One Infinity Rule by grensley on Saturday March 18, 2023 @09:43PM (#35215128)
Very fair, thanks for the example.
Re:Zero One Infinity Rule by ChainOfFools on Saturday March 18, 2023 @04:28PM (#35212804)
I seem to recall that there are certain languages (human languages) that have cases specifically for talking about pairs of objects, situated semantically between singular and plural. I think one of these is an archaic form of Greek, maybe ancient or Hellenistic.
Re:Zero One Infinity Rule by tough on Saturday March 18, 2023 @11:50PM (#35215861)
Asked ChatGPT

Yes, you are correct! Ancient Greek has a dual number, which is used specifically for referring to two people or two objects. The dual is a distinct grammatical number, separate from singular and plural.

In the ancient Greek language, nouns, pronouns, adjectives, and verbs all have different forms for singular, dual, and plural numbers. The dual number is used when referring to two things or two people, while the singular number is used for one thing or one person, and the plural number is used for three or more things or people.

The dual number is no longer used in modern Greek, but it was an important feature of the ancient Greek language, which had a rich and complex system of inflectional morphology. Other languages that have a dual number include Old English, Old Norse, Lithuanian, and Slovenian, among others.

Re:Zero One Infinity Rule by guavaNinja on Sunday March 19, 2023 @12:23AM (#35216012)
In Arabic there is the mothanna مثنى (pair) case.
Re:Zero One Infinity Rule by playingalong on Saturday March 18, 2023 @04:44PM (#35212919)
It has always "bothered" me that AWS allowed for up to two API keys per IAM user.
Re:Zero One Infinity Rule by jdreaver on Saturday March 18, 2023 @05:12PM (#35213154)
That's probably so you can rotate your keys without downtime.
Re:Zero One Infinity Rule by alex_sf on Saturday March 18, 2023 @04:59PM (#35213053)
The argument against two would be: if you can do two, why can you not do three?
Re:Zero One Infinity Rule by GauntletWizard on Saturday March 18, 2023 @05:32PM (#35213301)
* * *
Re:Zero One Infinity Rule by mmphosis on Saturday March 18, 2023 @06:32PM (#35213829)
Re:Zero One Infinity Rule by teo_zero on Saturday March 18, 2023 @07:03PM (#35214091)
I'd say that 2 is indeed quite common in Computer science. In graphs, for example, each edge has 2 ends. In an abstract syntax tree, a binary operator has 2 children. All raster images are based on 2 dimensions. A "for each" loop often involves 2 variables: the iterator object and an index.

In all such cases it makes sense that a language/ construct/library special-cases 2 elements without generalizing for an arbitrary number of elements.

By the way, 3 is much less common, except in some specific domains, like 3D vectors, UNIX permissions (user, group, other), etc.

Re:Zero One Infinity Rule by Kim_Bruning on Saturday March 18, 2023 @08:08PM (#35214534)
Oh, you're right, there are a few other exceptions for other numbers too!
Re:Zero One Infinity Rule by xigoi on Sunday March 19, 2023 @04:33AM (#35217105)
Usually you wouldn't store these things in a collection, but as separate fields of a record type, so the rule doesn't apply.
Re:Zero One Infinity Rule by teo_zero on Sunday March 19, 2023 @11:01AM (#35219653)
The principle applies to all kinds of structures. For example a common way to implement a generic tree that respects this rule is to model each node with exactly one parent and any number of children. My statement instead is that you may have legitimate reasons to want exactly one parent and from zero to two children, but not more.
Re:Zero One Infinity Rule by xigoi on Sunday March 19, 2023 @11:10AM (#35219752)
What would be the use case of such a tree?
Re:Zero One Infinity Rule by teo_zero on Monday March 20, 2023 @07:26PM (#35240342)
An Abstract Syntax Tree, where each node can have zero children (e.g. a literal value), one child (unary operator like 'Not') or two children (a binary operator like +).
Re:Zero One Infinity Rule by xigoi on Tuesday March 21, 2023 @01:36AM (#35242869)
And what exactly is the benefit of restricting such a tree to two children? Why not just allow an arbitrary amount of children and then only use it with 0,1,2? After all, you might later want to extend the language.
Re:Zero One Infinity Rule by teo_zero on Tuesday March 21, 2023 @02:18AM (#35243044)
Allowing arbitrary number of children doesn't come for free. You might need a linked list, which is a waste of memory and access time if you always just use up to two elements. What most parsers do is to provide exactly 2 slots, aptly named left and right, and use zero, one or both of them.