Return a one-dimensional ndarray formed by appending provided scalar values to a one-dimensional input ndarray.
var push = require( '@stdlib/ndarray/push' );Returns a one-dimensional ndarray formed by appending provided scalar values to a one-dimensional input ndarray.
var array = require( '@stdlib/ndarray/array' );
var x = array( [ 1.0, 2.0, 3.0, 4.0 ] );
var out = push( x, 5.0, 6.0, 7.0 );
// returns <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ]The function accepts the following arguments:
- x: input ndarray. Must be one-dimensional.
- ...values: scalar values to append.
Appends scalar values to a one-dimensional input ndarray and assigns the result to a one-dimensional output ndarray.
var array = require( '@stdlib/ndarray/array' );
var zeros = require( '@stdlib/ndarray/zeros' );
var x = array( [ 1.0, 2.0, 3.0, 4.0 ] );
var y = zeros( [ 7 ] );
var out = push.assign( x, 5.0, 6.0, 7.0, y );
// returns <ndarray>[ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ]
var bool = ( out === y );
// returns trueThe function accepts the following arguments:
var discreteUniform = require( '@stdlib/random/discrete-uniform' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var push = require( '@stdlib/ndarray/push' );
var opts = {
'dtype': 'generic'
};
var x = discreteUniform( [ 6 ], 0, 10, opts );
console.log( ndarray2array( x ) );
var out = push( x, 12, 14 );
console.log( ndarray2array( out ) );