How to realize Cartesian product of array

problem background: when you encounter this requirement in development, if the objects in an array are in the following format, can you do Cartesian product operation according to the difference of sidePos to get the following strings of different sidePos fields? The test field does not have any meaning, but only indicates the field name

item.value = `{"test": {"sidePos": "", "val": 0}, {"sidePos": "", "val": 1}}`
item.value = `{"test": {"sidePos": "", "val": 0}, {"sidePos": "", "val": 4}}`
item.value = `{"test": {"sidePos": "", "val": 2}, {"sidePos": "", "val": 1}}`
item.value = `{"test": {"sidePos": "", "val": 2}, {"sidePos": "", "val": 4}}`
item.value = `{"test": {"sidePos": "", "val": 3}, {"sidePos": "", "val": 1}}`
item.value = `{"test": {"sidePos": "", "val": 3}, {"sidePos": "", "val": 4}}`

beginners ask for advice ~

Mar.02,2021

  1. put "hundred" in one array and "ten" in another
  2. the result array of two-layer loops combined into nimm elements

pseudo code:

for each i in 
    for each j in 
        result.push(i + j)

another way of implementation:

  1. two-layer loop. Determine whether the two elements are the same in the inner loop. If they are not the same, they are combined. If the same is the same, skip
.

pseudo code:

for each i in arr
    for each j in arr
        if (i.sidePos != j.sidePos)
            result.push(i + j)

I don't understand what you are

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37aca-2c0bc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37aca-2c0bc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?