diff --git a/base/assert/is-mostly-safe-data-type-cast/README.md b/base/assert/is-mostly-safe-data-type-cast/README.md index 26e4c381..0720d231 100644 --- a/base/assert/is-mostly-safe-data-type-cast/README.md +++ b/base/assert/is-mostly-safe-data-type-cast/README.md @@ -73,19 +73,17 @@ bool = isMostlySafeCast( 'float64', 'int32' ); ```javascript -var cartesianSquare = require( '@stdlib/array/base/cartesian-square' ); +var cartesianSquare = require( '@stdlib/array/cartesian-square' ); var dtypes = require( '@stdlib/ndarray/dtypes' ); var isMostlySafeCast = require( '@stdlib/ndarray/base/assert/is-mostly-safe-data-type-cast' ); // Generate a list of dtype pairs: -var pairs = cartesianSquare( dtypes() ); +var dt = cartesianSquare( dtypes() ); // For each data type pair, determine whether one can cast to another data type... -var dt; var i; -for ( i = 0; i < pairs.length; i++ ) { - dt = pairs[ i ]; - console.log( '%s => %s. Can cast? %s.', dt[ 0 ], dt[ 1 ], isMostlySafeCast( dt[0], dt[1] ) ); +for ( i = 0; i < dt.length; i++ ) { + console.log( '%s. Can cast? %s.', dt[i].join( ' => ' ), isMostlySafeCast.apply( null, dt[i] ) ); } ``` diff --git a/base/assert/is-mostly-safe-data-type-cast/examples/index.js b/base/assert/is-mostly-safe-data-type-cast/examples/index.js index c1643b81..1a8732e8 100644 --- a/base/assert/is-mostly-safe-data-type-cast/examples/index.js +++ b/base/assert/is-mostly-safe-data-type-cast/examples/index.js @@ -18,17 +18,15 @@ 'use strict'; -var cartesianSquare = require( '@stdlib/array/base/cartesian-square' ); +var cartesianSquare = require( '@stdlib/array/cartesian-square' ); var dtypes = require( './../../../../dtypes' ); var isMostlySafeCast = require( './../lib' ); // Generate a list of dtype pairs: -var pairs = cartesianSquare( dtypes() ); +var dt = cartesianSquare( dtypes() ); // For each data type pair, determine whether one can cast to another data type... -var dt; var i; -for ( i = 0; i < pairs.length; i++ ) { - dt = pairs[ i ]; - console.log( '%s => %s. Can cast? %s.', dt[ 0 ], dt[ 1 ], isMostlySafeCast( dt[0], dt[1] ) ); +for ( i = 0; i < dt.length; i++ ) { + console.log( '%s. Can cast? %s.', dt[i].join( ' => ' ), isMostlySafeCast.apply( null, dt[i] ) ); } diff --git a/base/assert/is-safe-data-type-cast/README.md b/base/assert/is-safe-data-type-cast/README.md index 68329237..05865ae4 100644 --- a/base/assert/is-safe-data-type-cast/README.md +++ b/base/assert/is-safe-data-type-cast/README.md @@ -73,25 +73,17 @@ bool = isSafeCast( 'float64', 'int32' ); ```javascript +var cartesianSquare = require( '@stdlib/array/cartesian-square' ); var dtypes = require( '@stdlib/ndarray/dtypes' ); var isSafeCast = require( '@stdlib/ndarray/base/assert/is-safe-data-type-cast' ); -var DTYPES; -var bool; -var dt; +// Generate a list of dtype pairs: +var dt = cartesianSquare( dtypes() ); + +// For each data type pair, determine whether one can safely cast from one data type to another... var i; -var j; - -// Get a list of supported ndarray data types: -DTYPES = dtypes(); - -// For each data type, determine whether one can safely cast to another data type... -for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - for ( j = 0; j < DTYPES.length; j++ ) { - bool = isSafeCast( dt, DTYPES[ j ] ); - console.log( '%s => %s. Safe? %s.', dt, DTYPES[ j ], bool ); - } +for ( i = 0; i < dt.length; i++ ) { + console.log( '%s. Safe? %s.', dt[i].join( ' => ' ), isSafeCast.apply( null, dt[i] ) ); } ``` diff --git a/base/assert/is-safe-data-type-cast/examples/index.js b/base/assert/is-safe-data-type-cast/examples/index.js index 2d42d753..684f664e 100644 --- a/base/assert/is-safe-data-type-cast/examples/index.js +++ b/base/assert/is-safe-data-type-cast/examples/index.js @@ -18,23 +18,15 @@ 'use strict'; +var cartesianSquare = require( '@stdlib/array/cartesian-square' ); var dtypes = require( './../../../../dtypes' ); var isSafeCast = require( './../lib' ); -var DTYPES; -var bool; -var dt; -var i; -var j; - -// Get a list of supported ndarray data types: -DTYPES = dtypes(); +// Generate a list of dtype pairs: +var dt = cartesianSquare( dtypes() ); -// For each data type, determine whether one can safely cast to another data type... -for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - for ( j = 0; j < DTYPES.length; j++ ) { - bool = isSafeCast( dt, DTYPES[ j ] ); - console.log( '%s => %s. Safe? %s.', dt, DTYPES[ j ], bool ); - } +// For each data type pair, determine whether one can safely cast from one data type to another... +var i; +for ( i = 0; i < dt.length; i++ ) { + console.log( '%s. Safe? %s.', dt[i].join( ' => ' ), isSafeCast.apply( null, dt[i] ) ); } diff --git a/base/assert/is-same-kind-data-type-cast/README.md b/base/assert/is-same-kind-data-type-cast/README.md index abf66e84..27017292 100644 --- a/base/assert/is-same-kind-data-type-cast/README.md +++ b/base/assert/is-same-kind-data-type-cast/README.md @@ -73,25 +73,17 @@ bool = isSameKindCast( 'uint16', 'int16' ); ```javascript +var cartesianSquare = require( '@stdlib/array/cartesian-square' ); var dtypes = require( '@stdlib/ndarray/dtypes' ); var isSameKindCast = require( '@stdlib/ndarray/base/assert/is-same-kind-data-type-cast' ); -var DTYPES; -var bool; -var dt; +// Generate a list of dtype pairs: +var dt = cartesianSquare( dtypes() ); + +// For each data type pair, determine whether one can cast from one data type to another... var i; -var j; - -// Get a list of supported ndarray data types: -DTYPES = dtypes(); - -// For each data type, determine whether one can cast to another data type... -for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - for ( j = 0; j < DTYPES.length; j++ ) { - bool = isSameKindCast( dt, DTYPES[ j ] ); - console.log( '%s => %s. Allowed cast? %s.', dt, DTYPES[ j ], bool ); - } +for ( i = 0; i < dt.length; i++ ) { + console.log( '%s. Allowed cast? %s.', dt[i].join( ' => ' ), isSameKindCast.apply( null, dt[i] ) ); } ``` diff --git a/base/assert/is-same-kind-data-type-cast/examples/index.js b/base/assert/is-same-kind-data-type-cast/examples/index.js index fdbc5464..91ecf9bd 100644 --- a/base/assert/is-same-kind-data-type-cast/examples/index.js +++ b/base/assert/is-same-kind-data-type-cast/examples/index.js @@ -18,23 +18,15 @@ 'use strict'; +var cartesianSquare = require( '@stdlib/array/cartesian-square' ); var dtypes = require( './../../../../dtypes' ); var isSameKindCast = require( './../lib' ); -var DTYPES; -var bool; -var dt; -var i; -var j; - -// Get a list of supported ndarray data types: -DTYPES = dtypes(); +// Generate a list of dtype pairs: +var dt = cartesianSquare( dtypes() ); -// For each data type, determine whether one can cast to another data type... -for ( i = 0; i < DTYPES.length; i++ ) { - dt = DTYPES[ i ]; - for ( j = 0; j < DTYPES.length; j++ ) { - bool = isSameKindCast( dt, DTYPES[ j ] ); - console.log( '%s => %s. Allowed cast? %s.', dt, DTYPES[ j ], bool ); - } +// For each data type pair, determine whether one can cast from one data type to another... +var i; +for ( i = 0; i < dt.length; i++ ) { + console.log( '%s. Allowed cast? %s.', dt[i].join( ' => ' ), isSameKindCast.apply( null, dt[i] ) ); }