Last active
February 28, 2023 17:28
-
-
Save TracyGJG/9b91b0c2e8c9fbc060836d9ca13642ac to your computer and use it in GitHub Desktop.
SIMD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
"use strict"; | |
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } | |
function sisd2simd(sisdFn) { | |
return function (data) { | |
var params = sisdFn.length; | |
console.log(params, data.length); | |
while (data.length) { | |
var args = data.splice(0, params); | |
sisdFn.apply(undefined, _toConsumableArray(args)); | |
} | |
}; | |
} | |
function sisd(x, y) { | |
console.log(x * (y || 1)); | |
} | |
var simd = sisd2simd(sisd); | |
simd(2, 5, 6, 7, 8); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function sisd2simd(sisdFn) { | |
return (data) => { | |
var params = sisdFn.length; | |
console.log(params, data.length); | |
while(data.length) { | |
var args = data.splice(0, params); | |
sisdFn(...args); | |
} | |
} | |
} | |
function sisd(x, y) { console.log(x * (y || 1)); } | |
const simd = sisd2simd( sisd ); | |
simd(2, 5, 6, 7, 8); | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } } | |
function sisd2simd(sisdFn) { | |
return function (data) { | |
var params = sisdFn.length; | |
console.log(params, data.length); | |
while (data.length) { | |
var args = data.splice(0, params); | |
sisdFn.apply(undefined, _toConsumableArray(args)); | |
} | |
}; | |
} | |
function sisd(x, y) { | |
console.log(x * (y || 1)); | |
} | |
var simd = sisd2simd(sisd); | |
simd(2, 5, 6, 7, 8); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment