Re: length() of an atom

new topic     » goto parent     » topic index » view thread      » older message » newer message

Here is what Keneth Iverson defined for scalar values and vctors. In APL, a scalar is somewhat similar to atom nad is treated as a one element vector when an operation is performed which might make a vector. ⍝ is a comment character. I have added to make non-APLers comfortable. APL has no precedence. it executes from right to left. ⍴ is a monadic function for shape and ← is used for assignment - same as = in many languages.

      var1 ← 5  ⍝ // Assign a single value 5 to a variable called var1 
      var1 ⍝ // show what is in var1  
5 
      ⎕ ←  nshape ← ⍴ var1 ⍝ //shape of var1 assigned to nshape and show - result is nothing 
      ⍴ nshape ⍝ // nshape is actually an empty vector with shape of 0 
0 
      ⍴ nshape ⍝ // nshape is actually an empty vector with shape of 0 
0 
      ⍴ vshape ← var2 ← var1 , 12 18 43 ⍝ // , is a join function in APL 
4 
      var2 ⍝ // var2 is a join of var 1 and a three elment sequence. shape is 4 
5 12 18 43 

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu