Apl – a programming language

1,528 views 26 slides Nov 06, 2012
Slide 1
Slide 1 of 26
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26

About This Presentation

My current favorite language~


Slide Content

APL –A Programming Language
By Bryan Wilson

//TODO -Header
•Short History
•Brief APL Rundown
•APL Details and Tools
•Syntax
–Data, Structures, Classes
–Functions, Operands
–System Variables, Functions
•Expanding APL

30 Second History
•This language is crazy
•History sheds light on why

Enter Kenneth E. Iverson
Profession: Mathematics
“5 is greater than 1. Look”

His Notation
Relic found in ancient Mayan ruins.

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

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

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

Stop. Demotime.

Boring APL stuff
•Specifications
–ISO (International Standards Organization
–APL2, by IBM
•Interpreted
–Thus, Interpreters
•APL+
•APLX
•DyalogAPL
•VisualAPL

Interpreters
•Use workspaces, and have unique specs
–Workspace
–System Variables
–System Functions
•Modes
–Calculator mode
–Definition mode

Simple Data
•A number
–24595
–Can be decimal or negative
•A character
–‘s’
–Wrapped in single quotes
–‘Use two ‘’ to escape the ‘’ ‘

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

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

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

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

Classes
•Logical grouping of data and functions
„ŒNEW CLASSNAME
[classname].[function/property]
•Can have constructors.
•Some interpreters let you use external classes
–.NET

Alienspeak
•Arithmetic
+, -, ×, ÷, ⌈, ⌊, |
•Algebraic
⍳, ? , * , ⍟, ○, ! , ⌹
•Comparative
<, ≤, =, ≥, >, ≠, ≡, ∊, ⍳, ⍷
•Logical
~, ∨, ^, ⍱, ⍲
•Manipulative
⍴, ≡, , , ∊, ~, ⌽, ⍉, ↑, ↓, ⊂, ⊃

Continued Mathyspeak
•Sorting
⍋, ⍒, ⊤, ⊥
•Miscellaneous
⎕, ⍞, ⋄, ⍕, ⍝, ⍎, ⌷, ⌻,¯
•Operators
/, \, ., ∘. , ¨, []

Defining your own functions
•It can be done! Watch!

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

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

The future is J
•APL transformed to be easier to read
quicksort=: (($:@(<#[), (=#[), $:@(>#[)) ({~ ?@#))
^: (1<#)

Summary
•Simply put:
–Dynamic
–Abstract
–Powerful
–Awesome

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)

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
Tags