No relation to the sports channel.

  • 0 Posts
  • 25 Comments
Joined 2 years ago
cake
Cake day: June 9th, 2023

help-circle


  • Thing is, the economists are right about free markets being a good idea; and free markets depend on a certain kind of regulation to exist. The trouble with capitalism is that it’s never been a reliable ally of freedom of any sort; going back to the origins of capitalism in the private funding of colonial slaver monopolies. The association of capitalism with free markets is largely propaganda; capitalism started with colonial slaver monopolies like the VOC; to a first approximation every firm wants to be a monopoly, and a great way of doing that is political corruption; see today’s USA.

    But there’s a reason every government since ever — from empires to democracies — has done things like standardize weights & measures, build public goods like roads to enable trade, and establish courts of law to enforce contracts and fair dealing. Those things are really good ideas! And I’m not sure I can credit the left-anarchist proposals to replace them any more than I can credit the anarcho-capitalist ones.

    Mutualism sure has some nice ideas though.



  • I drifted slowly from right-libertarian to a more leftish position: pro-union, pro-social-programs, skeptical of the compatibility of unregulated capitalism with individual freedom. Still no fan of tankies.

    This wasn’t from anyone sitting down and trying to convince me, though. Part of it was discovering how close right-libertarianism had always been to white-supremacism: some old Ron Paul newsletters were unpleasantly enlightening. Part was seeing people who called themselves “libertarians” line up with the far right to support state violence, especially against black and brown people. And heck, part was from getting richer and seeing how that worked.

    I have a lot of sympathy for the frustrations that get young men into right-wing positions and occasionally I try to puncture some of the nonsense they’re being fed.
















  • The answer given in the spoiler tag is not quite correct!

    Test case

    According to the spoiler, this shouldn’t match “abab”, but it does.

    Corrected regex

    This will match what the spoiler says: ^.?$|^((.)\2+?)\1+$

    Full workup

    Any Perl-compatible regex can be parsed into a syntax tree using the Common Lisp package CL-PPCRE. So if you already know Common Lisp, you don’t need to learn regex syntax too!

    So let’s put the original regex into CL-PPCRE’s parser. (Note, we have to add a backslash to escape the backslash in the string.) The parser will turn the regex notation into a nice pretty S-expression.

    > (cl-ppcre:parse-string "^.?$|^(..+?)\\1+$")
    (:ALTERNATION
     (:SEQUENCE :START-ANCHOR (:GREEDY-REPETITION 0 1 :EVERYTHING) :END-ANCHOR)
     (:SEQUENCE :START-ANCHOR
      (:REGISTER
       (:SEQUENCE :EVERYTHING (:NON-GREEDY-REPETITION 1 NIL :EVERYTHING)))
      (:GREEDY-REPETITION 1 NIL (:BACK-REFERENCE 1)) :END-ANCHOR))
    

    At which point we can tell it’s tricky because there’s a capturing register using a non-greedy repetition. (That’s the \1 and the +? in the original.)

    The top level is an alternation (the | in the original) and the first branch is pretty simple: it’s just zero or one of any character.

    The second branch is the fun one. It’s looking for two or more repetitions of the captured group, which is itself two or more characters. So, for instance, “aaaa”, or “abcabc”, or “abbaabba”, but not “aaaaa” or “abba”.

    So strings that this matches will be of non-prime length: zero, one, or a multiple of two numbers 2 or greater.

    But it is not true that it matches only “any character repeated a non-prime number of times” because it also matches composite-length sequences formed by repeating a string of different characters, like “abcabc”.

    If we actually want what the spoiler says — only non-prime repetitions of a single character — then we need to use a second capturing register inside the first. This gives us:

    ^.?$|^((.)\2+?)\1+$.

    Specifically, this replaces (..+?) with ((.)\2+?). The \2 matches the character captured by (.), so the whole regex now needs to see the same character throughout.