apl – a programming language
DESCRIPTION
My current favorite language~TRANSCRIPT
![Page 1: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/1.jpg)
APL – A Programming Language
By Bryan Wilson
![Page 2: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/2.jpg)
//TODO - Header
• Short History
• Brief APL Rundown
• APL Details and Tools
• Syntax
– Data, Structures, Classes
– Functions, Operands
– System Variables, Functions
• Expanding APL
![Page 3: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/3.jpg)
30 Second History
• This language is crazy
• History sheds light on why
![Page 4: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/4.jpg)
Enter Kenneth E. Iverson
Profession: Mathematics “5 is greater than 1. Look”
![Page 5: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/5.jpg)
His Notation
Relic found in ancient Mayan ruins.
![Page 6: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/6.jpg)
A Pointless Language
• Entirely dynamic, highly abstract
• Largely interpreted (line by line execution)
• “Keywords” are symbols
• Tacit programming
• Short programs, probably about 1 line
• Write-only language
![Page 7: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/7.jpg)
How the magic happens
• Right to left evaluation, except for parens
5 + 5 10 5 x 5 25 5 × 5 + 5
50
(5 × 5) + 5
30
![Page 8: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/8.jpg)
Time to get crazy
• Types of data are largely done for you
1 2 3 + 5
6 7 8
¼9
1 2 3 4 5 6 7 8 9
2 4 ½¼9
1 2 3 4 5 6 7
8 9 1 2 3 4 5
![Page 9: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/9.jpg)
Stop. Demotime.
![Page 10: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/10.jpg)
Boring APL stuff
• Specifications
– ISO (International Standards Organization
– APL2, by IBM
• Interpreted
– Thus, Interpreters
• APL+
• APLX
• Dyalog APL
• VisualAPL
![Page 11: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/11.jpg)
Interpreters
• Use workspaces, and have unique specs
– Workspace
– System Variables
– System Functions
• Modes
– Calculator mode
– Definition mode
![Page 12: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/12.jpg)
Simple Data
• A number
– 24595
– Can be decimal or negative
• A character
– ‘s’
– Wrapped in single quotes
– ‘Use two ‘’ to escape the ‘’ ‘
![Page 13: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/13.jpg)
Data Structures
• May have data, has dimensions
• Data does not have dimensions
• Struct – 1 item, no dimensions
• Vector- 1d list of items
• Matrix -2D..nD list of items
• Item can be character, number or structure
• Data structures can have mixed data, or nested
![Page 14: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/14.jpg)
Data and structure syntax
• To store a variable [name] „ [variable]
• Names can start with a letter and NOTHING else
• Names can have numbers and some symbols
• Don’t duplicate names
![Page 15: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/15.jpg)
Functions
• Types – 0 arguments (niladic)
– 1 argument (monadic) • Everything to the right
– 2 arguments (dyadic) • Everything to the right
• First item to the left
• Can return data/data structure
• Bucket brigade
• Can be named like data
• One symbol, 1-2 functions, depending on arguments
![Page 16: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/16.jpg)
Operations
• Modify the function of…functions.
– How functions are applied to data
• In addition to 0-2 arguments, can take 1-2 operands
• Functions can be operands
• Can also be named like functions
![Page 17: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/17.jpg)
Classes
• Logical grouping of data and functions
„ŒNEW CLASSNAME
[classname].[function/property]
• Can have constructors.
• Some interpreters let you use external classes
– .NET
![Page 18: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/18.jpg)
Alienspeak • Arithmetic
+, -, ×, ÷, ⌈, ⌊, |
• Algebraic ⍳ , ? , * , ⍟, ○, ! , ⌹
• Comparative <, ≤, =, ≥, >, ≠, ≡, ∊, ⍳, ⍷
• Logical ~, ∨, ^, ⍱, ⍲
• Manipulative ⍴, ≡, , , ∊, ~, ⌽, ⍉, ↑, ↓, ⊂, ⊃
![Page 19: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/19.jpg)
Continued Mathyspeak
• Sorting
⍋, ⍒, ⊤, ⊥
• Miscellaneous
⎕, ⍞, ⋄, ⍕, ⍝, ⍎, ⌷, ⌻,¯
• Operators
/, \, ., ∘. , ¨, [ ]
![Page 20: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/20.jpg)
Defining your own functions
• It can be done! Watch!
![Page 21: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/21.jpg)
System Variables and Functions
• Variables
– Easy to pick out, they start with Œ
– Change depending on interpreter
• Functions
– Start with a )
– Also change depending on interpreter
![Page 22: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/22.jpg)
Can’t cover everything!
• Can you have threads?
– Yes. Some interpreters.
• Can you have labels?
– In function and operation definitions.
– This includes if/else and try/catch blocks
• Where can I learn more?
– Classes quoted at ~$2000 per day per person
![Page 23: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/23.jpg)
The future is J
• APL transformed to be easier to read
quicksort=: (($:@(<#[), (=#[), $:@(>#[)) ({~ ?@#)) ^: (1<#)
![Page 24: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/24.jpg)
Summary
• Simply put:
– Dynamic
– Abstract
– Powerful
– Awesome
![Page 25: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/25.jpg)
Questions for YOU
1. ⍳9 Returns what?
1 2 3 4 5 6 7 8 9
2. What does an operator in APL do?
Changes how a function is applied to data
3. To create a 3 dimensional array:
(1 2 3) ⍴ (5 4)
![Page 26: Apl – a programming language](https://reader033.vdocuments.mx/reader033/viewer/2022051016/5599fe051a28ab08098b45f8/html5/thumbnails/26.jpg)
Questions for me?
There are three things a man must do
before his life is done
write two lines in APL,
and make the damn thing run