Table des matières

DSE / Data Query / For Loop

Conversion d'une liste de tuples en Map de tuples

/* Map yield ratio threshold data */
yield_ratio_threshold: Map<String, Tuple<matiere: String, min: Float, max: Float, average: Float>> = @yield_ratio_list.toMap(keyFunction: x => x.matiere, valueFunction: x => x);

Itération sur 2 tableaux de manière synchronisée

tableau1:List<String>=["A", "B", "C", "D"];
tableau2:List<String>=["value A", "value B", "value C", "value D"];
fusion:List<String>=List.range(startInclusive: 0, endExclusive: tableau1.length, step: 1 )
                  .map(index => tableau1[index] + "="+ tableau2[index]);

Résultat

["A=value A","B=value B","C=value C","D=value D"]

Créer d'une matrice croisant 2 chaines de caractère

term1:String="chien";
term2:String="niche";
matrix:List<List<String>>= List.range(0,term1.length)
    .map(index1 => List.range(0,term2.length)
        .map(index2 => term1.charAt(index1) + "-" +  term2.charAt(index2)
    )
) ;

Résultat

[["c-n","c-i","c-c","c-h","c-e"],["h-n","h-i","h-c","h-h","h-e"],["i-n","i-i","i-c","i-h","i-e"],["e-n","e-i","e-c","e-h","e-e"],["n-n","n-i","n-c","n-h","n-e"]]