My APL page
Here is some APL info. I tend to use Dyalog APL, and it's great dfns library which are often used here.
Some APL code
Note: I'm not sure how well the special APL characters are shown in every browsers. There is an APL font (APL385.ttf) downloable from Dyalog which hopefully will give good result. (Here is a direct link: Apl385.ttf)
For the Project Euler problems, I have used some functions (e.g. fibonacci
, factors
) from the dfns
library mentioned above (this may - or may not - be considering cheating).
- Euler1:
+/0=∧⌿3 5∘.|X/X←⍳999
- Euler2:
+/0=2|f/f←(4000000>f)/f←fibonacci¨⍳40
- Euler3:
⌈/factors 600851475143
- Euler4: Two version on the same theme:
- 1)
ispalin←{(⍴t)=+/(t)=(⌽t←⍕⍵)}
⌈/(∊ispalin¨P)/(P←∪∊,/A∘.×A← 99+⍳900)
- 2) With
ispalin
"expanded" as an anonymous function:
⌈/(∊{(⍴t)=+/(t)=(⌽t←⍕⍵)}¨P)/P←∪∊A∘.×A←99+⍳900
- Euler 5:
∧/⍳20
- Euler 6:
((+/s)*2)-+/(s←⍳100)*2
- Euler 7:
pco 10001
- Euler 8:(Note: This don't work so well in the interactive GUI since the long line is stripped. Better to put it in a function.)
A←'7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450'
⌈/×/⍎¨A[((⍳(⍴A)-4)-1)∘.+⍳5]
- Euler 9:
- I'm not very happy about this version; it has too many transposes...
×/∊(1↑(↓c)/⍨1000=+/c←↑(b,¨{⍵*0.5}+/↑b×b←,a∘.,a←⍳500))
- This is better, and shorter:
×/∊(1↑c/⍨(1000=+/¨c←b,¨{⍵*0.5}+/¨b×b←,a∘.,a←⍳500))
- Euler 10: This is a principal solution of the problem but it yields LIMIT ERROR:
(~v∊v∘.×v)/v←1↓⍳2e6
Using the dfun sieve:
+/sieve 2 to 2e6
Here is the recursive definition of sieve
sieve←{ ⍝ Sieve of Eratosthenes.
⍺←⍬ ⍝ Default no primes yet.
nxt←1↑⍵ ⍝ Next prime, and
msk←0≠nxt|⍵ ⍝ ... mask of non-multiples.
^/1↓msk:⍺,⍵ ⍝ All non multiples - finished.
(⍺,nxt)∇ msk/⍵ ⍝ Sieve remainder.
}
More about APL
Here are some links about APL.
- Try APL
- Wikipedia: APL, APL programming language family
- A lot of APL books
- The J site also has some related APL papers/books
-
- Kenneth E. Iverson: Notation as a Tool of Thought (PDF-version, originally published in the Communications of the ACM, Volume 23, Number 8, August 1980
- APL Wiki
- Dyalog APL (which is the system I tend to use), Documentation
- Mastering Dyalog APL, excellent tutorial in Dyalog APL (and "modern" APL). Also available as a PDF version. (Order as a paper book from Bokus Mastering Dyalog APL)
- Dyalog APL functions and algorithms
- Len Shustek: The APL Progamming Language Source Code (with source code for APL\360)
- Bernard LegrandAPL – a Glimpse of Heaven (Vector, and it is also about the introduction chapter in "Mastering Dyalog APL")
- Blog: APL – the programming language lightsaber
- Blog: Three Blind Mice - Follow Shaquil, Sam and James's journey into the world of APL.
- Video: Dyalog APL for old timers
- Introduction videos: APLTrainer (YouTube)
- Video The Origins of APL - 1974
- Video: Kenneth Iverson's Memorial
- Video: Conway's Game Of Life in APL
- Video: A Sudoku Solver in APL (algorithm by Arthur Whitney)
- Video: Palindromic Expression for Phi in APL
- A blog by Catherine Lathwell doing a feature film about the origins of APL: Chasing Men Who Stare at Arrays
- Videos: http://www.youtube.com/user/AProgrammingLanguage
- A Celebration of the life of Kenneth Eugene Iverson
- Video: 50 years of APL
- Videos: Talks from Dyalog '08
- Videos: Talks from Dyalog '09
- Videos: Talks from APL 2010
- Videos: Talks from Dyalog '11
- Videos: Talks from Dyalog '12
- Dyalog Conferences
- Dyalog '13 Conference
- Jim Weigang: JimW's APL Information with useful resources
- Journal of the British APL Association: Vector, Archive of Vector articles. Blog
- Usenet/Google group comp.lang.apl
- ACM SIGAPL
- FinnAPL, Idiom Library
- aplwiki.com: Unicode version of FinnAPL Idiom
- c2.com: AplLanguage
- RosettaCode: APL
- Bob Smith: APL Projects
- APL2JPhraseBook
- Eli, APL derivate with an ASCII-based operator set (Windows only)
- GNU APL 1.0, SVN repo, CVS repo (See discussion at HackerNews)
- ngn/apl: APL compiler written in CoffeeScript. Browser demo.
- YouTube: Morten Kromberg (Dyalog Ltd.) Talks at Google on (Dyalog) APL
Also see the related:
My K page
My J page
Back to my homepage.
Created by Hakan Kjellerstrand, hakank@gmail.com.