using APL apl"(ι5) ×∘ ι5" f = apl"{(ιω) ×∘ ιω}" f(5) apl"+/"(1:10) uniq = apl"{((ιρω) = (ω ι ω))]ω}" # ] is the getindex operator v = [3, 2, 1, 3, 4, 2, 1, 7, 4, 2, 2, 3] x = uniq(v) # Frequency distribution [x apl"{+/(α=∘ω)}"(x,v)] apl"16 16 16 ⊤ 877 123 43" apl"⊤"([1760,3,12],95) # 95 inches = 2 yards, 1 foot, 11 inches P=[2, 3, 7] # List of primes E=[2, 1, 2] # List of exponents #prod(P.^⊤(E+1 ,R ),1) apl"{×⌿α*(ω+1)⊤(⁻1+ι×/ω+1)}"(P, E) apl"6 5 ρ ⍋⍋,(ι6)+∘ι5" # Dijkstra's Question M=[3 16 10 11;5 1 14 14;19 8 6 17;1 2 11 14; 1 8 2 9; 14 12 19 17] x =apl"{ι¨ρω]ω}"(M) apl"{ (ω=(1]α) +∘ (2]α)) ] ω}"(x,M) apl"{ω⍉1 2}"(M),apl"{ω⍉2 1}"(M) @code_llvm apl"-"(1, 2) @code_llvm apl"-"(1, 2.0) @code_llvm 1-2 @code_llvm 1-2.0 @code_llvm apl"-⍨"(1,2) @code_llvm apl"-⍨⍨⍨⍨⍨⍨"(1,2) # Up to 6 flips get inlined! @code_llvm apl"-¨"([1,2,3]) # some things won't be inlined... apl"+/⍬",apl"×/⍬", apl"×/⍬", apl"⌈/⍬", apl"⌊/⍬", apl",/⍬", apl"⌈/⍬", apl"∧/⍬", apl"∨/⍬", apl"+/"(Bool[]) apl"+⍨/⍬",apl"×⍨/⍬", apl"×⍨/⍬", apl"⌈⍨/⍬", apl"⌊⍨/⍬", apl",⍨/⍬", apl"⌈⍨/⍬", apl"∧⍨/⍬", apl"∨⍨/⍬", apl"+⍨/"(Bool[])