AmesingFlank / taichi.js

Modern GPU Compute and Rendering in Javascript
https://taichi-js.com
MIT License
454 stars 20 forks source link

support `?:` operator #18

Closed FurryR closed 1 month ago

FurryR commented 1 month ago

Example 1:

await ti.kernel((a) => {
  return a === 1 ? 2 : a
})(1);

Example 2:

await ti.kernel({ a: ti.template(), b: ti.template(), c: ti.template() }, (a, b, c) => {
  return a === 1 ? b[a - 1] : c[a - 1];
})(1, [1, 2], [1, 2]);

Example 3:

await ti.kernel({ a: ti.template(), b: ti.template(), c: ti.template() }, (a, b, c) => {
  return (a === 1 ? b : c)[0];
})(1, [1, 2], [1, 2]);
FurryR commented 1 month ago

This issue seems duplicated. Closing.