A batch transform applies the same cleanup rule to each input value.

batch transform The loop applies one transformation to every value in the batch.
scalar output Joining the cleaned values keeps the replay output compact and readable.

Batch Transform

bonus
BatchTransform.java
Replay: real traced execution (multi-file project)
public class BatchTransform {
    static int clamp(int value) {
        if (value < 0) {
            return 0;
        }
        return value;
    }

    public static void main(String[] args) {
        int bonus = 1;
        int[] rawScores = {7, -1, 10};
        StringBuilder cleaned = new StringBuilder();

        for (int i = 0; i < rawScores.length; i++) {
            int value = clamp(rawScores[i] + bonus);
            if (i > 0) {
                cleaned.append(",");
            }
            cleaned.append(value);
        }

        System.out.println("scores=" + cleaned);
    }
}
public class BatchTransform {
    static int clamp(int value) {
        if (value < 0) {
            return 0;
        }
        return value;
    }

    public static void main(String[] args) {
        int bonus = -2;
        int[] rawScores = {7, -1, 10};
        StringBuilder cleaned = new StringBuilder();

        for (int i = 0; i < rawScores.length; i++) {
            int value = clamp(rawScores[i] + bonus);
            if (i > 0) {
                cleaned.append(",");
            }
            cleaned.append(value);
        }

        System.out.println("scores=" + cleaned);
    }
}
public class BatchTransform {
    static int clamp(int value) {
        if (value < 0) {
            return 0;
        }
        return value;
    }

    public static void main(String[] args) {
        int bonus = 4;
        int[] rawScores = {7, -1, 10};
        StringBuilder cleaned = new StringBuilder();

        for (int i = 0; i < rawScores.length; i++) {
            int value = clamp(rawScores[i] + bonus);
            if (i > 0) {
                cleaned.append(",");
            }
            cleaned.append(value);
        }

        System.out.println("scores=" + cleaned);
    }
}
  1. bonus ← 1, cleaned ← (empty)

    9public static void main(String[] args) {10    int bonus→ 1 = 1;  //@bonus=-2, 411    int[] rawScores = {7, -1, 10};12    StringBuilder cleaned→ (empty) = new StringBuilder();
  2. for (int i = 0; i < rawScores.length; i++)

    pass 1 of 3
    14for (int i0 = 0; i < rawScores.length3; i++) {15    int value = clamp(rawScores[i]7 + bonus1);16    if (i > 0) {
    All 3 passes — pass 1 is the card above
    passirawScores[i]
    107
    21-1
    3210
  3. static int clamp(int value)

    pass 1 of 3
    1public class BatchTransform {2    static int clamp(int value8) {3        if (value < 0) {4            return 0;5        }6        return value8;7    }
    All 3 passes — pass 1 is the card above
    passvalue
    18
    20
    311
  4. value ← 8

    14for (int i = 0; i < rawScores.length; i++) {15    int value→ 8 = clamp(rawScores[i]7 + bonus1);16    if (i > 0) {17        cleaned.append(",");18    }19    cleaned.append(value8);20}
    values this step0i
  5. value ← 0

    14for (int i = 0; i < rawScores.length; i++) {15    int value→ 0 = clamp(rawScores[i]-1 + bonus1);16    if (i > 0) {
    values this step1i
  6. if (i > 0)

    pass 1 of 2
    15int value = clamp(rawScores[i] + bonus);16if (i1 > 0) {17    cleaned.append(",");18}
  7. cleaned.append(value);

    18    }19    cleaned.append(value0);20}
  8. value ← 11

    14for (int i = 0; i < rawScores.length; i++) {15    int value→ 11 = clamp(rawScores[i]10 + bonus1);16    if (i > 0) {
    values this step2i
  9. if (i > 0)

    pass 2 of 2
    15int value = clamp(rawScores[i] + bonus);16if (i2 > 0) {17    cleaned.append(",");18}
  10. cleaned.append(value);

    18    }19    cleaned.append(value11);20}
  11. System.out.println("scores=" + cleaned);

    22    System.out.println("scores=" + cleaned8,0,11);23}
    outputscores=8,0,11
  1. bonus ← -2, cleaned ← (empty)

    9public static void main(String[] args) {10    int bonus→ -2 = -2;11    int[] rawScores = {7, -1, 10};12    StringBuilder cleaned→ (empty) = new StringBuilder();
  2. for (int i = 0; i < rawScores.length; i++)

    pass 1 of 3
    14for (int i0 = 0; i < rawScores.length3; i++) {15    int value = clamp(rawScores[i]7 + bonus-2);16    if (i > 0) {
    All 3 passes — pass 1 is the card above
    passirawScores[i]value
    107
    21-1-3
    3210
  3. static int clamp(int value)

    pass 1 of 3
    1public class BatchTransform {2    static int clamp(int value5) {3        if (value < 0) {4            return 0;5        }6        return value5;7    }
    All 3 passes — pass 1 is the card above
    passvalue
    15
    2-3
    38
  4. value ← 5

    14for (int i = 0; i < rawScores.length; i++) {15    int value→ 5 = clamp(rawScores[i]7 + bonus-2);16    if (i > 0) {17        cleaned.append(",");18    }19    cleaned.append(value5);20}
    values this step0i
  5. if (value < 0)

    2static int clamp(int value) {3    if (value-3 < 0) {4        return 0;5    }
  6. value ← 0

    14for (int i = 0; i < rawScores.length; i++) {15    int value→ 0 = clamp(rawScores[i]-1 + bonus-2);16    if (i > 0) {
    values this step1i
  7. if (i > 0)

    pass 1 of 2
    15int value = clamp(rawScores[i] + bonus);16if (i1 > 0) {17    cleaned.append(",");18}
  8. cleaned.append(value);

    18    }19    cleaned.append(value0);20}
  9. value ← 8

    14for (int i = 0; i < rawScores.length; i++) {15    int value→ 8 = clamp(rawScores[i]10 + bonus-2);16    if (i > 0) {
    values this step2i
  10. if (i > 0)

    pass 2 of 2
    15int value = clamp(rawScores[i] + bonus);16if (i2 > 0) {17    cleaned.append(",");18}
  11. cleaned.append(value);

    18    }19    cleaned.append(value8);20}
  12. System.out.println("scores=" + cleaned);

    22    System.out.println("scores=" + cleaned5,0,8);23}
    outputscores=5,0,8
  1. bonus ← 4, cleaned ← (empty)

    9public static void main(String[] args) {10    int bonus→ 4 = 4;11    int[] rawScores = {7, -1, 10};12    StringBuilder cleaned→ (empty) = new StringBuilder();
  2. for (int i = 0; i < rawScores.length; i++)

    pass 1 of 3
    14for (int i0 = 0; i < rawScores.length3; i++) {15    int value = clamp(rawScores[i]7 + bonus4);16    if (i > 0) {
    All 3 passes — pass 1 is the card above
    passirawScores[i]
    107
    21-1
    3210
  3. static int clamp(int value)

    pass 1 of 3
    1public class BatchTransform {2    static int clamp(int value11) {3        if (value < 0) {4            return 0;5        }6        return value11;7    }
    All 3 passes — pass 1 is the card above
    passvalue
    111
    23
    314
  4. value ← 11

    14for (int i = 0; i < rawScores.length; i++) {15    int value→ 11 = clamp(rawScores[i]7 + bonus4);16    if (i > 0) {17        cleaned.append(",");18    }19    cleaned.append(value11);20}
    values this step0i
  5. value ← 3

    14for (int i = 0; i < rawScores.length; i++) {15    int value→ 3 = clamp(rawScores[i]-1 + bonus4);16    if (i > 0) {
    values this step1i
  6. if (i > 0)

    pass 1 of 2
    15int value = clamp(rawScores[i] + bonus);16if (i1 > 0) {17    cleaned.append(",");18}
  7. cleaned.append(value);

    18    }19    cleaned.append(value3);20}
  8. value ← 14

    14for (int i = 0; i < rawScores.length; i++) {15    int value→ 14 = clamp(rawScores[i]10 + bonus4);16    if (i > 0) {
    values this step2i
  9. if (i > 0)

    pass 2 of 2
    15int value = clamp(rawScores[i] + bonus);16if (i2 > 0) {17    cleaned.append(",");18}
  10. cleaned.append(value);

    18    }19    cleaned.append(value14);20}
  11. System.out.println("scores=" + cleaned);

    22    System.out.println("scores=" + cleaned11,3,14);23}
    outputscores=11,3,14