Case: Difference between revisions

Jump to navigation Jump to search
Reference Mask rather than SIMD blend
(No idea what to call this page)
 
(Reference Mask rather than SIMD blend)
 
Line 1: Line 1:
{{Built-in|Case|%}}, or '''Merge''', is a [[dyadic]] [[primitive]] function in [[Kap]] and [[dzaima/APL]] that forms an array by mixing [[element]]s taken from a [[vector]] of arrays according to an array of [[index|indices]]. It's closely related to the [[J]] adverb ([[monadic operator]]) Composite Item <syntaxhighlight lang=j inline>}</syntaxhighlight>, which differs in that the right argument is an array whose [[major cell]]s are mixed together. It can also be considered a generalization of a blend instruction in [[wikipedia:SIMD|SIMD]] programming, which chooses between two arguments based on a boolean mask, an operation that might be written <syntaxhighlight lang=apl inline>(A∧~M)∨(B∧M)</syntaxhighlight> in APL.
{{Built-in|Case|%}}, or '''Merge''', is a [[dyadic]] [[primitive]] function in [[Kap]] and [[dzaima/APL]] that forms an array by mixing [[element]]s taken from a [[vector]] of arrays according to an array of [[index|indices]]. It's closely related to the [[J]] adverb ([[monadic operator]]) Composite Item <syntaxhighlight lang=j inline>}</syntaxhighlight>, which differs in that the right argument is an array whose [[major cell]]s are mixed together. It can also be considered a generalization of [[Mask]], which chooses between two arguments based on a boolean mask and might be implemented as <syntaxhighlight lang=apl inline>(A∧~M)∨(B∧M)</syntaxhighlight>.


The following example shows how Case may be used to mix three vectors together:
The following example shows how Case may be used to mix three vectors together:

Navigation menu