Pages

Aide TD max col

let TAB_MAX_Value = TAB.reduce((max_val,lig_val)=> Math.max(max_val,Math.max(...(lig_val))),Number.MIN_VALUE);



// ecriture => let TAB_Min = TAB.reduce((m,l) => Math.min(m,Math.min(...(l))),TAB[0][0]);


code source


Tapez chaque fonction dans pythontutor pour appréhender le comportement et donner la valeur résultante.

const TAB = [
  [0,0,30],
  [10,0,0],
  [0,20,0],
  ]


let A = TAB.map(function(x){
  return x
  });

let AA = TAB.map(function(l_val){
  return l_val
  });


let AAA = TAB.map(function(_,x){
  return x
  });

let AAA = TAB.map(function(_, l_num){
  return l_num
  });


let B = TAB[0].map(function(x){
  return x
});

let Bb = TAB[0].map(function(c0_val){
  return c0_val
});

let BB = TAB[0].map(function(_, col){
  return col
  });

  // TAB[0].map( (_, col) => col );


let C = TAB.reduce(function(x,y){
  console.log(`x=${x} | y = ${y}`)
});

let C_init = TAB.reduce(function(x,y){
  console.log(`x=${x} | y = ${y}`)
},0);

let CC = TAB.reduce(function(x,y){
  console.log(`x=${x} | y = ${y}`)
  return ++x
},0);

let CCC = TAB.reduce(function(acc,lig_val){
  console.log(`acc=${acc} | lig_val = ${lig_val}`)
  return ++x
},0);

let CCCC = TAB.reduce(function(acc,lig_val){
  console.log(`acc=${acc} | lig_val = ${lig_val}`)
  acc += lig_val.length;
  return acc
},0);

let CCCCC = TAB.reduce(function(acc,lig_val){
  console.log(`acc=${acc} | lig_val = ${lig_val}`)
  acc += lig_val[1];
  return acc
},0);

let CCCCCC = TAB.reduce(function(acc,lig_val){
  console.log(`acc=${acc} | lig_val = ${lig_val}`)
  console.log(`max =  ${Math.max(...(lig_val))}`)
  return acc
},0);


let val_max = TAB.reduce(function(max,lig_val){
  max=Math.max(acc,Math.max(...(lig_val)))
  return max
},Number.MIN_VALUE);

Lien