“for” comprehensions

You cannot view this unit as you're not logged in yet. Go to Account to login.

5 Comments

  1. Zac B on May 3, 2023 at 9:14 am

    This might be a little bit more concise (and especially with particularly large ranges). Took a few minutes to get it right as I don’t work with bitstring syntax much.

    for x <- ?a..?h,
    y <- 1..8 do
    %{col: "#{<>}”, row: y, name: “#{<>}#{y}”}
    end
    end

  2. Zac B on May 3, 2023 at 9:15 am

    Well that got munched. Should be (without extra spaces), < > (for example). Hopefully that doesn’t get munched…

  3. L0cutus on December 24, 2024 at 6:00 am

    Which is better: your solution, mine, or is there no difference?

    def team_points(users) do
    for %User{points: points, active: true} = user acc + points
    end
    end

    • L0cutus on December 24, 2024 at 6:00 am

      def team_points(users) do
      for %User{points: points, active: true} = user acc + points
      end
      end

    • L0cutus on December 24, 2024 at 6:02 am

      dunno why but it cut my code…

Leave a Comment

You must be logged in to post a comment.