Questions tagged [apl]

APL (named after the book A Programming Language) is an interactive array-oriented language. It is based on a mathematical notation developed by Kenneth E. Iverson. Do not use this tag for Alexa Presentation Language; use [alexa-presentation-language] instead.

Wiki

APL, short for A Programming Language, is an interactive array-oriented language and integrated development environment. It is an interpreted language with built-in array capabilities and outstanding debugging features that makes the language a perfect choice for the agile approach. APL is also the first functional programming language ever, and it is also considered as a tacit programming language.

Example

APL uses symbols, array comprehension, and implied Iverson brackets to make its code concise and enable thinking about it much like Mathematical formulas.

This example assigns the vector (list) value 4 5 6 7 to N:

N ← 4 5 6 7 

The code below then adds 4 to all elements of the vector (giving 8 9 10 11):

N + 4

Now we can get a Boolean mask indicating results of 10 or higher (giving 0 0 1 1):

10 ≤ N + 4

And sum that to find out how many sums fulfilled the criteria (giving 2):

+/ 10 ≤ N + 4

Tag usage

The tag should be used for programming related problems in implementing or using the APL programming language. Please avoid theoretical and conceptual questions on Stack Overflow. Other tags such as , or can also be used with tag . Make sure to specify which dialect you use, for example by using the tag.

Read more

341 questions
5
votes
4 answers

How do I do in F# what would be called compression in APL?

In APL one can use a bit vector to select out elements of another vector; this is called compression. For example 1 0 1/3 5 7 would yield 3 7. Is there a accepted term for this in functional programming in general and F# in particular? Here is my F#…
JonnyBoats
  • 5,177
  • 1
  • 36
  • 60
5
votes
5 answers

Is there a file type for APL programs?

Is there a way to open up a text editor, type up some APL code, save it as a file, and then open it in Dyalog or MicroAPLX to execute the code? Or is that what workspaces are?
5
votes
2 answers

examples to compare tradtional math notations vs APL/J notations

I am reading a review to compare Mathematica to APL/J. One question raised in the article seems very interesting to me: Is Mathematica really the way to go to express our creative thoughts – viz back to a 17th century notation designed for…
ahala
  • 4,683
  • 5
  • 27
  • 36
5
votes
3 answers

Pass function as an argument in APL

How do I pass a function as an argument? The basic idea is something like this (which doesn't work): ∇R ← double a R ← 2 × a ∇ ∇R ← a applytwice f R ← f f a ∇ 5 applytwice double Is there something like \fun in erlang or function-pointers in C?
Hyperboreus
  • 31,997
  • 9
  • 47
  • 87
5
votes
3 answers

APL: Matrix manipulation trick?

I'm trying to find a way (idiomatic or otherwise) to transform a matrix that looks like 0 1 0 1 0 1 into 3 individual matrices 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 so that when I OR all of them together, I get the original. Each of these…
Chris Zhang
  • 968
  • 7
  • 16
5
votes
2 answers

String Length with Scalars and Vectors in APL

I just started learning APL a couple of weeks ago, so this may sound like a newbie question. Let B be a string, which in APL terms can be either a scalor or a vector. If it's a scalar, ⍴B returns null rather than the length of the string as I…
Expedito
  • 7,771
  • 5
  • 30
  • 43
5
votes
4 answers

Core of APL, J, K

I'm trying to understand APL, J, K, and it's slightly frustrating since: Most books seen to be about APL, but few APL implementations, and I don't have weird keyboards. K appears to have been replaced by Q J doesn't seem to have I almost feel like…
user1311390
4
votes
4 answers

In SQL, How can I generate every possible unique combination of 5!56?

I have a TABLE "elements" with one COLUMN "number", type SMALLINT that contains numbers 1 thru 56. How can I generate unique sets of 5 numbers of every possible combination from 1 to 56, using an SQL statement? In APL (programming language) a simple…
Joe R.
  • 2,032
  • 4
  • 36
  • 72
4
votes
1 answer

APL Fork/Train with Compression

I want to select elements from an array based on some test. Currently, I am trying to do that with a compression, and I would like to write it as a tacit function. (I'm very new to APL, so feel free to suggest other options.) Below is a minimal…
j_v_wow_d
  • 511
  • 2
  • 11
4
votes
1 answer

How to turn a matrix of nested vectors into a vector of nested vectors

I am producing a matrix of pairs (= nested vectors) like so: x←⍳10 y←⍳10 x∘.,y But for further processing I need to have the pairs in one vector of pairs. If I apply ravel: ,/x∘.,y then the pairs are not anymore nested. How to transform the matrix…
Rudi Angela
  • 1,463
  • 1
  • 12
  • 20
4
votes
2 answers

Cannot use user commands in Dyalog APL

I just installed Dyalog-APL 18.0 on my windows(Windows 10) machine and when I tried using ]box on -style=max on the IDE I got the following error: FILE ACCESS ERROR: C:/Users//Documents/: Unable to read directory status Then I noticed that…
MrV
  • 169
  • 1
  • 7
4
votes
2 answers

How can I mask the scan operator in APL?

Assuming I have an array N ← 0 0 0 1 1 1 0 0 1, how can I apply the scan \ to achieve the array 0 0 0 1 2 3 0 0 1? +\N gives me 0 0 0 1 2 3 3 3 4 which is not what I want. +\¨⊆⍨N gives me | 1 2 3 | 1 | which is closer, but then I lose the…
mazin
  • 395
  • 2
  • 7
4
votes
1 answer

APL: array's element replacement and multiplication

Let's say in APL language, I have a 2D array of shape 10x3. I cannot figure it out how to: replace all the occurrence of some specific numbers (e.g. 1, 2, 3, 4) in the entire array with 0, 10, 100, 1000 respectively. So I want to map 1 to 0, 2 to…
4
votes
1 answer

How do I convert a vector of triplets to a 3xnx3 matrix in Dyalog APL?

I have a vector containing 9000 integer elements, where each group of 9 has 3 sub-groups that I'd like to separate out, resulting in a matrix with the shape 3 1000 3. Here's what I did: ⎕IO←0 m←(9÷⍨≢data) 9⍴data a←m[;0 1 2] b←m[;3 4 5] c←m[;6 7…
xpqz
  • 3,617
  • 10
  • 16
4
votes
2 answers

Dyalog APL: how to write standalone files that can be executed?

I now know how to use the APL interpreter, but I'm quite confused about how to write APL into a file and then run the said file. I currently write Dyalog APL using the ride IDE. What I now want to do is to: Use the ride IDE to develop programs (how…