Symbol Execute

From NARS2000
Jump to: navigation, search

⍎ — Execute a string — Keystroke ?ALT+X — Character 0000

Usage

Examples

Valid uses of Execute(⍎) operator in conjunction with and without the Each(¨ or dieresis) operator:
(The examples just below are generally listed in order of complexity, least complex = topmost, most complex = bottommost.)

         ⍎¨'99' '100'     ⍝Dieresis used and IS needed
   99 100
         A←'99'
         B←'100'
         ⍎¨A B
   99 100
         ⍎¨A '1' '2' '3'
   99 1 2 3
         ⍎¨ '99100'
   9 9 1 0 0
         ⍎¨A,B
   9 9 1 0 0
         ⍎'99' '100'     ⍝Dieresis NOT used in nearly the same as topmost case - ⍎¨'99' '100' - and generates a Domain Error
   DOMAIN ERROR
         ⍎'99 100'       ⍝Dieresis NOT used and was not needed
   99 100
         C←99.8
         D←100.2
         ⍎'C D'          ⍝Dieresis NOT used and was not needed
   99.8 100.2
         ⍎'E←45000.78 ⋄ F←88765.321'    ⍝The diamond operator(⋄) is used to separate APL lines of code and IS supported in NARS
         E
   45000.78
         F
   88765.321

Note that the Execute operator was primarily-originally designed to convert character representations of numbers into actual digital numbers with a floating point or integer computer storage format. It was specifically designed to generate an error message when a non-digit such as a letter(e.g. 'A' or 'B' or even 'C' or 'D' was attempted to be converted to digital or computer binary format. In short, if you look at the code just above, you will see that yes Execute will convert char digits into numbers with or without the Each(dieresis) Operator.

The key is using the correct syntax to achieve your desired results, either:

  1. Separating every defined argument into '1' '2' '3' '4' vectorized char arguments or
  2. First placing char data digits into vars(A and B) and then executing each without any quote chars.

Also, note how the Execute function's use has been expanded over time to carefully under valid (Workspace variable name(s) known/recognized) circumstances yes execute or convert non-digit chars, e.g. variables C and D in quotes above. Note how execution/conversion of variables C and D into, in this case, a floating point numeric vector did NOT require the Each operator. Further vars C and D are considered floating point or real number vars while A and B are string vars which convert to integer numbers. The inclusion or omission of the ravel(,) operator also can make a big difference, e.g.:

         ⍎¨A B        ⍝Two-element(2 numbers) vector result
   99 100
         ⍎¨A,B        ⍝Five-element(5 single-digit numbers) vector result
   9 9 1 0 0

Another 2 examples, (1st example: Execute dbl-quote A is assigned quote quote dbl-quote):

         ⍎"A←''"
         A
                 ⍝Viewing variable A shows nothing, since it represents an empty string.
         ⍴A      ⍝Execute has created a zero-length string variable A in the current workspace.
   0
                 ⍝Another Execute example, in this case taking a string and executing it through APL's interpreter to arithmetically multiply two variables together.
         A←99
         B←100
         ⍎'A×B'
   9900

In short, the Execute(⍎) function is very powerful in APL/APL2 when correctly used and has a broad range of uses, particularly inside user defined functions - to create/convert information from string representations. First try using Execute without the dieresis operator, then if you are unable to achieve the desired results, try including the dieresis operator or change usage/calling syntax, e.g. with/without the ravel(,) operator.

See Also

Dieresis or Each Operator.

NARS 2000 Lang
Tool
Bar
+ - × ÷ * ! ? |
= < >
~ § π .. ,
/ \ ¨ .
_ ¯ Ø b e g p r v x