I will use if statements in my code and there's nothing you can do to stop me.

I will use if statements in my code and there's nothing you can do to stop me.

Homeless People Are Sexy Shirt $21.68

Nothing Ever Happens Shirt $21.68

Homeless People Are Sexy Shirt $21.68

  1. 2 weeks ago
    Anonymous

    I doubt there is anyone here on IQfy that cares enough to even think about trying.

    • 2 weeks ago
      Anonymous

      Most people on /g probably don't even know how to write this

  2. 2 weeks ago
    Anonymous

    doesn't python use elif and not else if

    • 2 weeks ago
      Anonymous

      Thanks, haven't used it in a while

  3. 2 weeks ago
    Anonymous

    Worked for Undertale.

    • 2 weeks ago
      Anonymous

      Undertale source leak?

      • 2 weeks ago
        Anonymous

        Undertale has every line of dialogue in the game within one giant if statement. It's nested dozens deep.

        • 2 weeks ago
          Anonymous

          And yet Toby is a multimillionaire

          • 2 weeks ago
            Anonymous

            Yep. I learned this from a man with a deep voice and luxurious hair and lots of ferrets. He told me to make my own game, so I'm doing it a little at a time. I'm currently stalled, though.

          • 2 weeks ago
            Anonymous

            >Thor(PirateSoftware)
            He's invading your recommendation section as well I see.

          • 2 weeks ago
            Anonymous

            And yet Toby is a homosexual who makes games that rationalize the protagonist as guilty for defending themselves. What's your point?

          • 2 weeks ago
            Anonymous

            My point is that successful don't obsess over trivial details that don't matter when your software will be run on hyper-optimized microchips, they just make good stuff.

          • 2 weeks ago
            Anonymous

            That Toby cries all the way to the bank when poorgay NEETs pick apart his code for not being le good optimized code.

          • 2 weeks ago
            Anonymous

            Kys bloodthirsty mutt

          • 2 weeks ago
            Anonymous

            That doesn't make (You)r code any less shit, anon.

          • 2 weeks ago
            Anonymous

            Exactly. Look at the source code from all those leaked military weapons years back, I remember seeing caps of various sections and they were also hilariously shit but they got the job done.
            Unless you are making a game, physics sim or similar, nobody gives a frick.
            Just don't use C++, whatever the frick you do.
            That language was a legit mistake and is still a meme, a very unfortunate meme that still persists like Java, a cancer infecting the industry.
            C chads run this shit, get microwaved c**ts.

        • 2 weeks ago
          Anonymous

          May I see it?

          • 2 weeks ago
            Anonymous

            No.

        • 2 weeks ago
          Anonymous

          >who cares if end users don't feel the significant performance difference... le written code just bad... it just is ok!!!!!
          This is why IQfy codecels will never understand end users enough to achieve fricking year of the linux desktop or build an actual GOOD FOSS shit.

        • 2 weeks ago
          Anonymous

          >people still repeating this shit
          that code screenshot was shat out by a decompiler. it's not the actual source

          • 2 weeks ago
            Anonymous

            if it was a decompiler doesn't that mean that whatever people write is just getting compiled into giant if else blocks anyway so it doesn't matter kek

          • 2 weeks ago
            Anonymous

            >compiled into giant if else blocks
            moron there's no if-else in asm.

          • 2 weeks ago
            Anonymous

            the decompiler has to guess what algorithms were used. No decompiler in existence can take a binary and return good quality C code from it, let alone match the original source.

          • 2 weeks ago
            Anonymous

            You underestimate the stupidity of many programmers, especially those working on internal programs for businesses. There are numerous examples of live, in-use code that use if-else chains to check for odd numbers, convert strings to numbers and all sorts of other poor uses of conditionals. Python especially is prone to this since it doesn’t have a switch statement, you just use a dictionary of functions instead, which not everyone figures out.

          • 2 weeks ago
            Anonymous

            I don't underestimate anything moron. I just don't assume that obviously decompiled machine code is any way reflective of the actual source code that produced it.

          • 2 weeks ago
            Anonymous

            Python isn’t compiled dipshit, at best you’d be “decompiling” Python bytecode. There is only one way to do conditionals in Python, using if else. The more idiomatic way of doing what the OPs function does would be to use a list or dictionary, which would not be converted to COMP_OP operations, but into a single BINARY_SUBSCR operation.

          • 2 weeks ago
            Anonymous

            >python
            dumb frick read the reply chain.

          • 2 weeks ago
            Anonymous

            If it was the Undertale screenshot, then sure, theres a decent chance it was decompiled. GameMaker has the option to compile its scripts, or the code was otherwise generated from dialogue files or similar. Seems likely actually, given it’s been localised into a few other languages.

  4. 2 weeks ago
    Anonymous

    Jest Werked for Undertale

  5. 2 weeks ago
    Anonymous

    >compiler see the instruction and make a efficient assembly out of it
    >zoomers in their 20s making their first python script throw a tantrum

    • 2 weeks ago
      Anonymous

      >Python
      >Compiler

      • 2 weeks ago
        Anonymous

        yes?

  6. 2 weeks ago
    Anonymous

    It would be more efficient to return the value by indexing a tuple.
    def path_order_render(n: int) -> Tuple[int, int]:
    return (
    (0, 0), # unused filler value
    (1, 0),
    (1, -1),
    (0, -1),
    (-1, -1),
    (-1, 0),
    (-1, 1),
    (0, 1)
    (1, 1)
    )[n]

    • 2 weeks ago
      Anonymous

      EDIT: comma after (0, 1).

      • 2 weeks ago
        Anonymous

        EDIT 2: Thank you for the reddit gold, kind stranger!

        • 2 weeks ago
          Anonymous

          Hell yeah, good idea thanks

          I guess you stopped me. I kneel

    • 2 weeks ago
      Anonymous

      Hell yeah, good idea thanks

    • 2 weeks ago
      Anonymous

      It would be more efficient to use a switch statement instead of creating an object and discarding 90% of it.

      • 2 weeks ago
        SAGE

        >creating an object
        >what is static data

      • 2 weeks ago
        Anonymous

        Is the tuple created each time the function runs, or just once when it's parsed by the interpreter? I'm assuming the latter since the tuple is compile-time constant

        It's in the function's set of constants, so it only gets created once when the program is first started.

    • 2 weeks ago
      Anonymous

      Is the tuple created each time the function runs, or just once when it's parsed by the interpreter? I'm assuming the latter since the tuple is compile-time constant

    • 2 weeks ago
      Anonymous

      remove (0, 0), put (1, 1) as the 0th element, and AND n by 8

    • 2 weeks ago
      Anonymous

      In Rust this is just
      fn path_order_render(n: i32) -> (i32, i32) {
      [
      (0, 0), // unused filler value
      (1, 0),
      (1, -1),
      (0, -1),
      (-1, -1),
      (-1, 0),
      (-1, 1),
      (0, 1),
      (1, 1),
      ]
      .iter()
      .copied()
      .nth(n.try_into().unwrap())
      .unwrap()
      }

      • 2 weeks ago
        Anonymous

        Wow, that is terrible. Is this a falseflag?
        This is simpler and better in every conceivable way:
        fn path_order_render(n: i32) -> (i32, i32) {
        match n {
        0 => (1, 0),
        1 => (1, -1),
        2 => (0, -1),
        3 => (-1, -1),
        4 => (-1, 0),
        5 => (-1, 1),
        6 => (0, 1),
        7 => (1, 1),
        _ => panic!(),
        }
        }

        • 2 weeks ago
          Cpt.Autism

          fn path_order_render(n: i32) -> (i32, i32) {
          match n {
          0 => ( 1, 0),
          1 => ( 1,-1),
          2 => ( 0,-1),
          3 => (-1,-1),
          4 => (-1, 0),
          5 => (-1, 1),
          6 => ( 0, 1),
          7 => ( 1, 1),
          _ => panic!(),
          }
          }

        • 2 weeks ago
          Anonymous

          Yeah, that's how i would've dome it. Thanks for confirming, anon.

      • 2 weeks ago
        Anonymous

        Wow, that is terrible. Is this a falseflag?
        This is simpler and better in every conceivable way:
        fn path_order_render(n: i32) -> (i32, i32) {
        match n {
        0 => (1, 0),
        1 => (1, -1),
        2 => (0, -1),
        3 => (-1, -1),
        4 => (-1, 0),
        5 => (-1, 1),
        6 => (0, 1),
        7 => (1, 1),
        _ => panic!(),
        }
        }

        Why can't you just type "return", you homosexuals?

  7. 2 weeks ago
    Anonymous

    >morons unironically believe that writing spaghetti code will make them millionaires
    never change, IQfy

  8. 2 weeks ago
    Anonymous

    def path_order_render(n):
    return (n==1 and (1, 0)) or (n==2 and (1, -1)) or (n==3 and (0, -1)) or (n==4 and (-1, -1)) or (n==5 and (-1, 0)) or (n==6 and (-1, 1)) or (n==7 and (0, 1)) or (n==8 and (1, 1))

    Fixed. This is the pythonic way.

  9. 2 weeks ago
    Anonymous

    What about using a dictionary?

    • 2 weeks ago
      Anonymous

      A list is better in this case.

      It would be more efficient to return the value by indexing a tuple.
      def path_order_render(n: int) -> Tuple[int, int]:
      return (
      (0, 0), # unused filler value
      (1, 0),
      (1, -1),
      (0, -1),
      (-1, -1),
      (-1, 0),
      (-1, 1),
      (0, 1)
      (1, 1)
      )[n]

  10. 2 weeks ago
    Anonymous

    If you change the order you can simply do this.
    """
    0 -> (-1, -1)
    1 -> (-1, 0)
    2 -> (-1, 1)
    3 -> (0, -1)
    4 -> (0, 0)
    5 -> (0, 1)
    6 -> (1, -1)
    7 -> (1, 0)
    8 -> (1, 1)
    """
    def path_order_render(n):
    return (n//3%3 - 1, n%3 - 1)

  11. 2 weeks ago
    Anonymous

    from math import sin,cos,pi
    def path_order_render(n):
    x = -2*pi*(n-1)/8
    m = max(abs(cos(x)), abs(sin(x*~~
    return round(cos(x)/m), round(sin(x)/m)

    • 2 weeks ago
      Anonymous

      Bloat, cos/sine of 45deg is way over 0.5

      • 2 weeks ago
        Anonymous

        your mother is bloat

    • 2 weeks ago
      Anonymous

      >computing at runtime instead of using a lookup table
      Pyjeets, not even once, and thats with their molasses lang.

      In Rust this is just
      fn path_order_render(n: i32) -> (i32, i32) {
      [
      (0, 0), // unused filler value
      (1, 0),
      (1, -1),
      (0, -1),
      (-1, -1),
      (-1, 0),
      (-1, 1),
      (0, 1),
      (1, 1),
      ]
      .iter()
      .copied()
      .nth(n.try_into().unwrap())
      .unwrap()
      }

      >.unwrap()

      • 2 weeks ago
        Anonymous

        you should always compute instead of using lookup tables

    • 2 weeks ago
      Anonymous

      >computing at runtime instead of using a lookup table
      Pyjeets, not even once, and thats with their molasses lang.
      [...]
      >.unwrap()

      It's a clever solution, don't be so dismissive. Branchlesss programming is kind of dumb but it's cooler and more in-line with mathematics.

  12. 2 weeks ago
    Anonymous

    >not elif
    Ngmi

  13. 2 weeks ago
    Anonymous

    No this is moronic.
    What you should do is load the target address and jump
    the target address should be computed as a base address + an offset
    the offset should be computable from your conditionals
    finally the code in the range of valid target adresses should be small enough so the entire thing can be piped into the cache so you dont get a cache miss

  14. 2 weeks ago
    Anonymous

    lists:nth(N,
    [{1,0},
    {1,-1},
    {0,-1},
    {-1,-1},
    {-1,0},
    {-1,1},
    {0,1},
    {1,1}]).

  15. 2 weeks ago
    Anonymous

    Would be more readable if you used a dict. Also you don't handle the case of n>8 or n<1

  16. 2 weeks ago
    Anonymous

    that's just an array if pairs/vector2

  17. 2 weeks ago
    Anonymous

    Consider this pythonic approach instead:

    return tuple([round(- math.sin ( (2*math.pi)/8*x)) for x in [n - 3, n - 1]])

  18. 2 weeks ago
    Anonymous

    You will notice the following advantages:
    - The function now works for numbers outside the range 1:9
    - The maths is explicit. For scientific uses consider using math.tau.
    - Single line of code
    - list comprehension is both powerful and beautiful
    - Self documenting

  19. 2 weeks ago
    Anonymous

    in haskell this is just
    pathOrderRender = (!!) [(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1),(0,1),(1,1)] . (+) (-1)

    • 2 weeks ago
      Anonymous

      You can do " . (-) 1"
      but still based.

      (the minus symbol is our only weakness)

      • 2 weeks ago
        Anonymous

        no you can't I'm stupid...

        (flip (-) 1)

Your email address will not be published. Required fields are marked *