Python

I have this disgusting, 3 dimensional list. What dark spells do I need to type in so that the one dimensional list components with a number greater than 7 in their first place are removed, giving me the desired list

  1. 1 week ago
    Anonymous

    Silly anon
    Access the index of each list's first member using pointer arithmetic and if value >= 7 then pop the whole member

    • 1 week ago
      Anonymous

      I need a concise mechanism that would do the same for lists of many elements, not just the particular list I mentioned in the post.

    • 1 week ago
      Anonymous

      list[l[0]<=7 for l in list]

      do your own homework retard

  2. 1 week ago
    Anonymous

    list[l[0]<=7 for l in list]

    • 1 week ago
      Anonymous

      list comprehension could work like mentioned

      i like numpy because it's specifically designed for 2+ dimensional arrays. you can do vectorized operations which are much faster than list comprehension.

  3. 1 week ago
    Anonymous

    You need to learn K&R or ANSI C.
    Then you'll solve your problem.

  4. 1 week ago
    Anonymous

    Try performing cross-dimensional matrix multiplication on the particular value that you want to remove.

  5. 1 week ago
    Anonymous

    go through number in 1st list in 1st list in 1st list
    go through number in 2nd list in 1st list in 1st list
    etc.
    >muh big O
    your asshole looks like a big O

  6. 1 week ago
    Anonymous

    use recursion

  7. 1 week ago
    Anonymous

    This is indeed very disgusting.
    It would look so much nicer with tuples.

  8. 1 week ago
    Anonymous

    [...]

    >homework thread
    this board is 18+

    • 1 week ago
      Anonymous

      I..don't have any hw. Ugh this was a waste of time

      • 1 week ago
        Anonymous

        >Ugh this was a waste of time
        >Ugh
        And now you "ugh" and "sigh" like a redditor.

        Yes this was a "waste" of OUR time. The sticky post says this is NO tech support board. Ask reddit for help not here.

        • 1 week ago
          Anonymous

          What's wrong about reddit? Lists are just so confusing I had to ask somewhere.

      • 1 week ago
        Anonymous

        fuck off dumbphone poster, there are literally 100 online pyhon interpreters that work from just a browser. not our fault you are shtoopid.

      • 1 week ago
        Anonymous

        Then why do you need it so urgently and spoon-fed?

  9. 1 week ago
    Anonymous

    map a lambda function over the list

  10. 1 week ago
    Anonymous

    Hire me!
    #!/usr/bin/env python3

    x=[[[1,2]], [[3,4], [5,6]], [[7,8], [9,10], [11,12]]]

    for i in reversed(range(0, len(x*~~:
    for j in x[i]:
    for el in j:
    if j[0] > 7:
    j.pop()
    while True:
    if len(j) == 0:
    break
    if j[-1] < 8:
    break
    j.pop()
    _x=[]
    for k in x[i]:
    if len(k) > 0:
    _x.append(k)
    x[i] = _x
    print(x)

    [[[1, 2]], [[3, 4], [5, 6]], [[7, 8]]]

    • 1 week ago
      Anonymous

      Does it have to be this big? I was expecting it to only take
      2-3 lines

      • 1 week ago
        Anonymous

        >Does it have to be this big?
        No

        • 1 week ago
          Anonymous

          >No
          Prove it.

          • 1 week ago
            Anonymous

            >Prove it.
            Proved in

            >I was expecting it to only take
            >2-3 lines
            Only one line needed provided you use list comprehensions:
            y = [[x2 for x2 in x1 if x2[0] <= 7] for x1 in x]
            You can do something similar with numpy, but the syntax is different.

      • 1 week ago
        Anonymous

        >I was expecting it to only take
        >2-3 lines
        Only one line needed provided you use list comprehensions:
        y = [[x2 for x2 in x1 if x2[0] <= 7] for x1 in x]
        You can do something similar with numpy, but the syntax is different.

        • 1 week ago
          Anonymous

          Finally..

          • 1 week ago
            Anonymous

            finally what? ungrateful shit

    • 1 week ago
      Anonymous

      Holy fuck anon that is hideous, have you ever heard of list comprehensions? Or functional programming?

  11. 1 week ago
    Anonymous

    >not using a single list to store elements in a 3 dimensional space
    Kek

Your email address will not be published.