Prototype: Difference between revisions

Jump to navigation Jump to search
6 bytes added ,  05:49, 9 June 2020
m
Text replacement - " ⊢( *[^∘])" to " ⎕←$1"
m (Categories)
m (Text replacement - " ⊢( *[^∘])" to " ⎕←$1")
Line 22: Line 22:
An array's prototype is based on its first element, so the array <source lang=apl inline>a</source> below has a simple numeric prototype, as does any prefix of <source lang=apl inline>a</source>. This property even applies to empty arrays: the expression <source lang=apl inline>0 ↑ a</source> results in an empty array with the same prototype as <source lang=apl inline>a</source>.  
An array's prototype is based on its first element, so the array <source lang=apl inline>a</source> below has a simple numeric prototype, as does any prefix of <source lang=apl inline>a</source>. This property even applies to empty arrays: the expression <source lang=apl inline>0 ↑ a</source> results in an empty array with the same prototype as <source lang=apl inline>a</source>.  
<source lang=apl>
<source lang=apl>
       ⊢a ← 5 'c' ¯2
       ⎕←a ← 5 'c' ¯2
5 c ¯2
5 c ¯2
       4 ↑ a
       4 ↑ a
Line 35: Line 35:
The prototype of an array may be [[nested]]. Here, we inspect the prototype of an array containing both character and numeric data. In the prototype, all characters are converted to spaces and all numbers to zeros. Thus the prototype retains type and structure information but not specific values.
The prototype of an array may be [[nested]]. Here, we inspect the prototype of an array containing both character and numeric data. In the prototype, all characters are converted to spaces and all numbers to zeros. Thus the prototype retains type and structure information but not specific values.
<source lang=apl>
<source lang=apl>
       ⊢x ← ⊂'de'(3 4 5)  ⍝ A complicated scalar array
       ⎕←x ← ⊂'de'(3 4 5)  ⍝ A complicated scalar array
┌──────────┐
┌──────────┐
│┌──┬─────┐│
│┌──┬─────┐│

Navigation menu