• 0 Posts
  • 225 Comments
Joined 1 year ago
cake
Cake day: July 10th, 2024

help-circle
  • I wasn’t talking about (just) the ingredient list in plant based meat alternatives, but rather about food ingredients in general. Seems like I said it in a slightly confusing manner.

    My point is: several food items that can be purchased list ingredients that are not easy to understand nor evaluate for a layperson. This is confusing. In contrast, “plant based” labled food is not difficult to understand, imo.





  • From what I have gathered, when I read through some criminology papers, it’s less about the severity of punishment and more about being caught and prosecuted which is more effective as a deterrence.

    The death penalty for example has been proven in numerous studies to be ineffective.

    Consequently, increasing the severity of punishments can become useless and possibly more based in a (public) desire for revenge.

    We, as a more or less civilised society, should also be mindful about why we prosecute someone and how we want to treat people in the long run. For example, just imprisioning someone for life – apart from being ethically debatable – will not solve problems but only move them somewhere else.










  • switch case structures are very efficient in c and c++. They work similarly like an offset into memory. Compute the offset once (any expression in the ‘case’ lines), then jump. Using primitives directly, like here with chars, is directly the offset. Contrary to if-else branches, where each case must be evaluated first and the CPU has basically no-op cycles in the pipeline until the result of the branch is known. If it fails, it proceeds with the next one, waits again etc… (Some CPU architectures might have stuff like speculative branch execution, which can speed this up.)

    However, code-style wise this is really not elegant and something like your proposal or similar would be much better.


  • At first I thought, "How are they going to compress 256 values, i.e. 1 Byte sized data, by “rearranging into integers”?

    Then I saw your code and realized you are discarding 228 of them, effectively reducing the available symbol set by about 89%.

    Speaking of efficiency: Since chars are essentially unsigned integers of size 1 byte and ‘a’ to ‘z’ are values 97 to 122 (decimal, both including) you can greatly simplify your turn_char_to_int method by just substracting 87 from each symbol to get them into your desired value range instead of using this cumbersome switch-case structure. Space (32) and dot (46) would still need special handling though to fit your desired range.

    Bit-encoding your chosen 28 values directly would require 5 bit.