aplnb IPython magic

Provides apl magics in Jupyter and IPython
__file__ = './00_core.ipynb'

source

APLMagic

 APLMagic ()

Initialize self. See help(type(self)) for accurate signature.


source

create_magic

 create_magic (shell=None)
# Only required if you don't load the extension
create_magic()
%%apl
x←⍳3  ⍝ Set x to positive integers up to 3
[1, 2, 3]
%%apl
x←⍳3  ⍝ Set x to positive integers up to 3
[1, 2, 3]
%apl x  ⍝ Get the value of x
[1, 2, 3]
%%apl
⎕←x;  ⍝ Add a ';' to skip returning the last result
1 2 3
x = %apl x
x
[1, 2, 3]
%apl ⎕A
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

source

load_ipython_extension

 load_ipython_extension (ipython)

Required function for creating magic


source

create_ipython_config

 create_ipython_config ()

Called by aplnb_install to install magic

def dyalog_cmd():
    "Helper function to get shell command to run Dyalog"
    dyalogscript_path = Path(which('dyalogscript.bash'))
    cts = dyalogscript_path.read_text()
    install_dir = re.search(r'^INSTALLDIR="([^"]*)"', cts, flags=re.MULTILINE).group(1)
    install_dir = "/Applications/Dyalog-19.0.app/Contents/Resources/dyalog"
    script_dir = os.environ.get('SCRIPT_DIR', install_dir)
    return f'{script_dir}/dyalog APLKEYS="{install_dir}/aplkeys" APLTRANS="{install_dir}/apltrans"'
dyalog_cmd()
'/Applications/Dyalog-19.0.app/Contents/Resources/dyalog/dyalog APLKEYS="/Applications/Dyalog-19.0.app/Contents/Resources/dyalog/aplkeys" APLTRANS="/Applications/Dyalog-19.0.app/Contents/Resources/dyalog/apltrans"'