added a convenience method (jx.utils.join)

The function is designed to perform a cartesian product of 2 vectors of the same length. The preconditions must be enforced as always by the calling code
@pre : v1.length == v2.length && v1.constructor == v2.constructor && v1.constructor == Array
master
Steve L. Nyemba 9 years ago
parent 579818d7aa
commit a236f732cb

@ -89,6 +89,20 @@ jx.utils.unique = function (list,getKey){
})
}
}
jx.utils.join = function(x,y){
if(x.length != y.length){
return []
}else{
var rec = x ;
for(var i in rec){
//
//@TODO: Consider the case we are adding to a matrix
//
rec[i] = [x[i],y[i]]
}
return rec ;
}
}
/**
* Implementation of a few standard design patterns. Their use is user/dependent
* For more information on how/when to use a design pattern please use google/wikipedia ;-)
@ -169,3 +183,4 @@ jx.utils.patterns.observer = function(lobservers,init){
* @return array containing casted type
*/
jx.utils.cast = jx.utils.patterns.visitor ;

Loading…
Cancel
Save