Hacker Newsnew | past | comments | ask | show | jobs | submit | SaddledBounding's commentslogin

The government didn't invalidate a legal contract; the contract is simply no longer legal. If your position is that the government should never make laws that contravene existing practices, then I have to disagree. In practice, that would mean the government could never make any laws, or could only make laws that have no practical effect, because everyone was already obeying them of their own accord.

Also note that in this particular case, "in 2011 they’d been told there was no issue with their gardens, and also that before 2017, they’d received no violations for their yard despite regular inspections", and note that the legal dispute between the couple and the HOA was settled outside of court; that is to say the parties came to an agreement outside of the formal legal system.


'e' ^ 'f' ^ 'g' == 0x40. Uh-oh.

Edit: I misread the post; my bad. The post effectively uses a bit vector to store the last N chars in a window, and the bit vector happens to fit in a single machine word. Also, XOR happens to be a good way to update the bit vector, because it turns out it's sufficient to store how many times each character appears in the window mod 2.

So to be clear, my "demonstration" above only works because the ASCII representations of e, f, and g are not linearly independent with respect to xor. However in the article, the representations of all of the characters are chosen to be a linearly independent set.


Ah OK, the article is actually suggesting making a list of Booleans whose length equals the number of possible characters. It just happens that it's assuming 26 allowed characters which fit in the bits of a 64 bit number.

The running time is does not depend on the window length, but does depend on the number of possible characters. If it's all of Unicode for example you'd be stuffed: you could fix the vector of values in memory (currently there are approx. 150,000 unicode code points), even if you used a byte per value, but counting number of true values will require iterating over the whole vector.

Even just going from 26 Latin letters to 256 byte values makes this trick quite messy unless your language has a really nice bit vector type (admittedly many do).

This comment was helpful for me to understand what was going on, even though it's a mistake followed by a correction.


The example code in the article left out the lookup table to convert each character into a single bit representation. All the tricky xor and popcount stuff could have been a 26 byte array just as easily and been O(n).


There's no lookup table. The example code in the article does the conversion using this expression:

    1 << (s[i + j] as u32 - 'a' as u32)


Yes, for some additional explanation for those that might use it, that's "ASCII math": it assumes all lowercase ASCII Latin letters (which most Unicode encodings including UTF-8 and UTF-32 inherit). ASCII was intentionally designed so that the lowercase letters a-z are in English alphabet order and so subtracting 'a' from the letter gives you an alphabet position number from 0-25. (The same applies in ASCII for the upper case range A-Z and the numerical range 0-9, though doing math between ranges is less fun.)

Then you've just got a standard single 1 left shifted 0-25 positions. (So 'a' is 1 and 'z' is 1*2^25.)


I do not believe it follows from "Much much more people die from processed foods/air pollution in the world than from motorway accidents" that nobody should care about speeding and motorway accidents. After all, far fewer people still are murdered, but the consensus seems to be that we care about murderers.


We can only think about one thing, and that thing must be the most horrible or offensive, rather than the more likely/dangerous. Hence the obsession with terrorists hiding under every rock while ignoring deaths from opioids, smoking, obesity, and COVID. Libertarians would rather be anal probed at every airport than wear a mask on a commuter train.


The higher your speed, the higher your speed differential with the road and guard rail. A car nudging another at 250 km/h can cause the other to violently roll over, while a car nudging another at 40 km/hr can't. Speed differential between cars is not the only factor in safety.


The title needs to be changed, because:

> This isn’t meant as a lens tutorial. Prerequisites are some basic knowledge of how to use Haskell, GHCI, and familiarity of the idea of lenses, if not the specifics.

With that out of the way, it's kind of disappointing that the article isn't a tutorial. As it is, it just lists the lens operators, gives you alternate, but still non-obvious names for them, and foists some exercises upon you. It could have easily given one short example for each operator without adding any significant tedium for those who already have an idea of what they do, and then it would have been a perfectly fine tutorial.

So here's some examples, (Hoogle has some nice examples too; thanks Hoogle):

    person = Person {_name = "Alice", _title = "Dr"}

    -- get field with magic lens
    person ^. title == "Dr"

    -- create new object with new field value
    person & name .~ "Bob"
        == person & (name .~ "Bob")
        == (name .~ "Bob") person
        == Person {_name = "Bob", _title = "Dr"}

    -- create new object with function applied to field value
    person & name %~ lowercase
        == (name %~ lowercase) person
        == Person {_name = "alice", _title = "Dr"}


utf-8 has an elegance that utf-16 lacks:

    utf-8 decode
      switch (std::countl_one(unit)) {
        case 0:
          /* one unit */
          break;
        case 2:
          /* two units */
          break;
        case 3:
          /* three units */
          break;
        case 4:
          /* four units */
          break;
        default:
          /* not code point boundary */
          break;
      }


Oh, thanks, this one is good. Must be rather fast on major platforms. But with this optimization UTF-8 still remains harder computationally than UTF-16.


I’m happy every time I see c++20 in the wild


It's because the grandparent comment has misconceptions about nutrition, including that animal products are necessary for a healthful diet and how much protein is required for a healthful diet.

The first misconception is contradicted by extensive analysis by health organizations such as [Academy of Nutrition and Dietetics][1]. Healthful vegan diets are no less healthful than healthful non-vegan diets.

The second misconception is about how much protein is needed in a healthful diet. Many people wildly overestimate how much protein a person needs, especially when strength training. It is not difficult to get sufficient protein within a given calorie budget while on a vegan diet, even without using protein supplements. For instance, tofu and seitan have protein to calorie ratios similar to meat, with seitan often having a higher protein to calorie ratio than most meats.

[1]: https://pubmed.ncbi.nlm.nih.gov/27886704/


Go and have a look at the amino acid profiles of seitan and tofu and also their bioavailability in comparison to meat and vegetarian protein sources. And you can talk all you want about people overestimating protein macro but 1 to 2 grams per lb of bodyweight has consistently shown to be optimal. You’ll be hard pressed to find any high performing athlete who isn’t aiming for that outside of endurance sports.

At the end of the day in my experience, a vegan diet is both a lot more hard work and less healthy than a non vegan one. Saying that a vegan diet isn’t any less healthy than a meat eating or vegetarian one is an absolute joke, especially considering there are no vegan foods containing vitamin B12 outside of yeast flakes and artificial supplements.


Amino acids - it's suboptimal to eat only one source of protein. I suppose more so on for a vegan. Just as well no one does that. Of they do you're no longer attributing "poor amino acid profiles" to veganism as you are to the person responsible for terrible diet.

B12 - Animal products come from animals filled to the brim with B12 supplements, of which a huge majority of global B12 supplements go towards livestock. Also along with over lovely concoctions of antibiotics and drugs.

There's nothing wrong with cutting out the middle-man! Not least when so many flesh eaters are also deficient in B12 themselves. In need of taking the same B-complex as vegans.


I think a demo of the transpiler output for a short function would make a great addition to the readme.


The vast majority of people in the Hacker News community clearly take offense to your view. Perhaps you should take a moment to consider your own antisocial behavior and quietly not express your opinion. After all, we need to compromise and can't just say as we please.


My comment is perfectly within the community guidelines of this site. You’ve unwittingly proven my point - communities have guidelines and by-laws.


You misunderstand me; I agree with you, which is why I think we should quiet down and not upset the sensibilities of the majority in the community. I understand why you would assume my comment is not in good faith, and I do not hold it against you, but this is not the community to air such concerns, as that violates the community guidelines.


> The proposed syntax is probably a consequence of a modern trend...

ML uses `name: type = value`. It came out over a decade before C++ and just one year after C.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: