Symbol Take: Difference between revisions

From NARS2000
Jump to navigationJump to search
(new)
 
(Added examples, expanded)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
<h1> {take} &mdash; (Replace this with Meaning of symbol) &mdash; Keystroke ?ALT+X &mdash; Character 0000</h1>
<h1> {take} &mdash; Take symbol &mdash; Keystroke(usually) ALT+y ; Character (⎕UCS) 8593</h1>
==Usage==
==Usage==
==Example==
'''Dyadic function A↑B''' - where '''A''' is the number of elements to take and '''B''' is the vector or array to operate on.
Take first(A is positive) n or last(A is negative) n elements of an array.
'''Take''' and '''Rho''' share a similar property - the left argument specifies the '''size''' of the resultant array.
==Examples==
 
<pre>
      5↑1    ⍝Take the first 5 elements, given scalar integer 1
1 0 0 0 0    ⍝Result creates a vector of 5 elements, since only a single scalar was present, 4 additional zeroes are appended to the vector.
 
      ¯4↑45 78 33 99 10 11 12 13  ⍝Take the last 4 elements, given a vector of 8 integers
10 11 12 13  ⍝APL/NARS Interpreter returns the last 4 elements, a vector.
 
      ¯5↑'abcdefghijklmnop' 
lmnop    ⍝Result is the last 5 elements from the alphabet sub-string(take's right argument), result is similarly a string.
 
      A←3 4⍴⍳12  ⍝Store a 3-row by 4-column matrix of the set of integers from 1 through 12 in variable A
      A  ⍝Display the contents of variable A, which has 3 rows and 4 columns of consecutive integers:
1  2  3  4
5  6  7  8
9 10 11 12
      2 3↑A    ⍝Take just the FIRST 2 rows and 3 columns of variable A, display the requested results:
1 2 3
5 6 7
 
      ¯2 3↑A  ⍝Take the LAST 2 rows and FIRST 3 columns of variable A, display the results:
5  6  7
9 10 11
 
      4 5↑A    ⍝Take 4 rows and 5 columns of variable A, ZEROES are APPENDED when left arguments exceed array sizes of a NUMERIC matrix.
1  2  3  4 0
5  6  7  8 0
9 10 11 12 0
0  0  0  0 0
 
      ¯4 ¯5↑A  ⍝Take negative 4 rows and negative 5 cols of variable A. Result: ZEROES are PREFIXED onto numeric matrix A:
0 0  0  0  0
0 1  2  3  4
0 5  6  7  8
0 9 10 11 12
 
</pre>
 
==See Also==
==See Also==
 
* [[Rho]]:  '''⍴''' especially '''Dyadic rho''' and it's leftmost argument




{{Language Toolbar}}
{{Language Toolbar}}
[[Category:Mouse Group 6|T]]
[[Category:Symbols|T]]

Latest revision as of 17:25, 13 February 2016

↑ — Take symbol — Keystroke(usually) ALT+y ; Character (⎕UCS) 8593

Usage

Dyadic function A↑B - where A is the number of elements to take and B is the vector or array to operate on. Take first(A is positive) n or last(A is negative) n elements of an array. Take and Rho share a similar property - the left argument specifies the size of the resultant array.

Examples

      5↑1    ⍝Take the first 5 elements, given scalar integer 1
1 0 0 0 0    ⍝Result creates a vector of 5 elements, since only a single scalar was present, 4 additional zeroes are appended to the vector.

      ¯4↑45 78 33 99 10 11 12 13  ⍝Take the last 4 elements, given a vector of 8 integers
10 11 12 13   ⍝APL/NARS Interpreter returns the last 4 elements, a vector.

      ¯5↑'abcdefghijklmnop'  
lmnop     ⍝Result is the last 5 elements from the alphabet sub-string(take's right argument), result is similarly a string.

      A←3 4⍴⍳12   ⍝Store a 3-row by 4-column matrix of the set of integers from 1 through 12 in variable A
      A   ⍝Display the contents of variable A, which has 3 rows and 4 columns of consecutive integers:
1  2  3  4
5  6  7  8
9 10 11 12
      2 3↑A    ⍝Take just the FIRST 2 rows and 3 columns of variable A, display the requested results:
1 2 3
5 6 7

      ¯2 3↑A   ⍝Take the LAST 2 rows and FIRST 3 columns of variable A, display the results:
5  6  7
9 10 11

      4 5↑A    ⍝Take 4 rows and 5 columns of variable A, ZEROES are APPENDED when left arguments exceed array sizes of a NUMERIC matrix.
1  2  3  4 0
5  6  7  8 0
9 10 11 12 0
0  0  0  0 0

      ¯4 ¯5↑A  ⍝Take negative 4 rows and negative 5 cols of variable A. Result: ZEROES are PREFIXED onto numeric matrix A:
0 0  0  0  0
0 1  2  3  4
0 5  6  7  8
0 9 10 11 12

See Also

  • Rho: especially Dyadic rho and it's leftmost argument


NARS 2000 Lang
Tool
Bar
+ - × ÷ * ! ? |
< = >
~ § π .. ,
/ \ ¨ .
_ ¯
Second Row i j k i j k l g p r v x