Now that we have finished all APL primitives, we will go through a subset of the system functions.
The name System Function is informally applied to all built-in names which begin with the quad symbol (⎕), even if they are actually operators, variables, or constants.
I will go roughly in the order given here. Feel free to interrupt with questions and comments.
System functions are things that are not really part of the core language, but have been wrapped into items which conform with normal APL syntax. You can therefore use system functions together with normal APL functions and operators. However, note that many system functions are "shy", meaning that they suppress implicit display of their result, and some even do this selectively.
Also note that these system variables can be localised. So if your dfn sets ⎕IO it only applies to that function (and its children), but does not permanently affect the environment.
@EriktheOutgolfer
Rebuilding user command cache... done
⍎VALUE ERROR: No result was provided when the context expected one
__field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄''''' ⋄ ⎕←(⍳4)({⎕IO←0 ⋄ }⍬) ⋄
∧
Real time: 1.078 s
User time: 0.939 s
Sys. time: 0.064 s
CPU share: 93.06 %
Exit code: 0
@EriktheOutgolfer Those are the types. In principle you could have 325 meaning 32-bit float or 2567 meaning 256-bit decimal. (Although they do not currently exist in Dyalog.)
@EriktheOutgolfer We will get back to more such codes later.
⎕RLRandom Link lets you set a seed value for random numbers so you can reproduce the same random numbers again. It also lets you choose which method to use for calculating the next random number based on the seed.
⎕RL is a two element array, but as opposed to normal arrays, you cannot modify ⎕RL in-place; you have to assign to the entire array at once.
The first element is the seed; an integer in the range 1 to ¯2+2*31. You can also use 0 to auto-randomise, or ⍬ to optimise by not keeping track of the seed.
The second element is the method. 0=Lehmer, 1=Mersenne, 2=ask the OS. (If you ask the OS, you can't provide a seed, so you have to use ⍬.)
@Adám You can evaluate an APL expression by typing it into chat prefixed by ⍞←. Use ⎕← instead for boxed display and multi-line results. Do not use markdown. Commands: )lb for language bar, )help for table of language elements, )docs for full documentation, )ref for PDF reference card.
⎕AIAccount Info is not very interesting these days, except you can use ⎕AI[3] as an absolute counter of milliseconds since the beginning of the session. This is useful to avoid having to deal with roll-overs when timing stuff.
⎕CLEAR is a special constant, which when referenced will clear the workspace just like )clear does. For the bot, this isn't useful, but you can try it online!
⎕CY is a function which copies from a workspace file to the current workspace. You give it the name of a workspace file as right argument, and optionally a name list on the left of items to copy. By default, it will copy everything.
Beware that ⎕CY annoyingly does not have a result in versions ≤16.0. We will fix this in 17.0 so it becomes easier to use in scripts, dfns, and tacit functions.
@EriktheOutgolfer That was considered, but it could have performance issues if you copy in a workspace with tens of thousands of functions. Instead it will be the list of functions not copied.
@EriktheOutgolfer In anticipation of an upcoming (this doesn't currently exist) ⎕PCY or a variant on ⎕CY which allows you to do a Protected copy by only copying things that would not overwrite existing items in the current workspace, similar to )PCOPY.
⎕←'I, APL, gracefully admit that I am not perfect. Therefore, you can see how much I actually waited, instead of the intended time period of one (1) second: ',⍕⎕DL 1
@EriktheOutgolfer
I, APL, gracefully admit that I am not perfect. Therefore, you can see how much I actually waited, instead of the intended time period of one (1) second: 1.001123
@Adám
Rebuilding user command cache... done
Cannot exit when fixing a class
⍎DOMAIN ERROR
__field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄''''' ⋄ ⎕←⎕OFF 42
∧
Real time: 0.988 s
User time: 0.898 s
Sys. time: 0.049 s
CPU share: 95.91 %
Exit code: 0
However, ⎕SAVE has a trick up its sleeve. If you use ⎕SAVE under program control, you can then use ⎕LOAD on the generated workspace file, and execution will continue where the ⎕SAVE happened, with ⎕SAVE giving the result 0.
This allows you to write applications where the user can close the application and then resume the left-off state when opening the application again.
@RosLuP
Rebuilding user command cache... done
⍎VALUE ERROR
__field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄''''' ⋄ ⎕←⎕LOAD file123
∧
Real time: 1.096 s
User time: 1.002 s
Sys. time: 0.045 s
CPU share: 95.58 %
Exit code: 0
@Adám
Rebuilding user command cache... done
Cannot load workspace when fixing a class
⍎DOMAIN ERROR
__field_initialize_result_←(⎕NS ⍬).⍎'⎕CY''salt''⋄⎕SE.UCMD''←box on -fns=on -trains=tree''⊣enableSALT⋄''''' ⋄ ⎕←⎕LOAD'dfns'
∧
Real time: 1.046 s
User time: 0.976 s
Sys. time: 0.036 s
CPU share: 96.78 %
Exit code: 0