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
1
vote
2 answers

How to assign APL expression to execute on pressing shortcut?

I have Dyalog APL 13.2.20611.0 64 Unicode session, and I have utility function, which I want to run on pressing shortcut. How can I configure this?
Oleksandr Nechai
  • 1,811
  • 16
  • 27
1
vote
2 answers

Apply function to each row of a matrix

I have a function that rotates a vector v of length 9 by offset in groups of 3: ∇ r ← offset rot3 v r ← , offset ⌽ 3 3 ⍴ v ∇ It seems to work: 2 rot3 ⍳ 9 3 1 2 6 4 5 9 7 8 And then a function that rotates a 9x9 matrix m horizontally by…
Hyperboreus
  • 31,997
  • 9
  • 47
  • 87
1
vote
2 answers

Error 'No Error' when omitting assignment

I am playing around with APL doing this problem. I have defined the following functions: ∇ r ← smallestFactor n ⍝ Find smallest factor of n r ← (0 = r) + r ← 1 ↑ (0 = r | n) / r ← 1 ↓ ⍳ n ∇ ∇ r ← factors n; sf ⍝ List of all prime factos…
Hyperboreus
  • 31,997
  • 9
  • 47
  • 87
1
vote
2 answers

Cumulative Maxima as Indicated by X in APL

The third item in the FinnAPL Library is called “Cumulative maxima (⌈) of subvectors of Y indicated by X ” where X is a binary vector and Y os a vector of numbers. Here's an example of its usage: X←1 0 0 0 1 0 0 0 Y←9 78 3 2 50 7 69…
Expedito
  • 7,771
  • 5
  • 30
  • 43
1
vote
1 answer

Ascending Cardinal Numbers in APL

In the FinnAPL Idiom Library, the 19th item is described as “Ascending cardinal numbers (ranking, all different) ,” and the code is as follows: ⍋⍋X I also found a book review of the same library by R. Peschi, in which he said, “'Ascending cardinal…
Expedito
  • 7,771
  • 5
  • 30
  • 43
1
vote
2 answers

Is there any way to tell the difference between a number 3.0 and 3 in APL?

Or 1 versus 1.0, or 2 versus 2.0... Ideally, is there an operation that will behave differently on one than the other?
Chris Zhang
  • 968
  • 7
  • 16
1
vote
1 answer

A+ and Emacs (but *not* XEmacs)

I have installed A+ and set up XEmacs in Debian, using the aplus-fsf-dev and aplus-fsf-el packages; XEmacs was installed as a dependency. I checked the A+ site (http://www.aplusdev.org/), and there seems to be nothing about running A+ on plain Emacs…
Jay
  • 9,585
  • 6
  • 49
  • 72
1
vote
1 answer

Dyalog APL - Parsing a vector of strings and appending a string to each vector.

I have a vector of input data given by A <-- Files.Dir '...directory' and this returns a vector of all the files in that directory. However, the path contains only the file names, not the full paths. What I want to do is to append the path stored in…
alvonellos
  • 1,009
  • 1
  • 9
  • 27
1
vote
2 answers

How do I use argument twice in a function in J?

I want to write prime function for purposes of learning J. So far I've come up with this: =&0+/(=&0)(2+i.(-&2)y)|y It's working great except that I should store number in y variable. y=.5 =&0+/(=&0)(2+i.(-&2)y)|y NB. prime cheker 1 …
defhlt
  • 1,775
  • 2
  • 17
  • 24
0
votes
2 answers

Boolean array in If guard

According to the Dyalog APL language reference the test condition to the right of :If must return a single element Boolean value 1 (true) or 0 (false) Is there any particular reason why the value is allowed to be an array rather than requiring it…
August Karlstrom
  • 10,773
  • 7
  • 38
  • 60
0
votes
1 answer

How to use compose operator in APL?

I'm not able to understand compose operator in APL. I have tried but precedence is the issue that I am facing.
0
votes
3 answers

how to print values between 2 numbers in APL?

I am not able to print values ranging from 30 to 50 both inclusive in APL. Actually I tried so much operators but not working.
0
votes
3 answers

APL2, order of processing each operator arguments

Assuming the user function: ∇ f b [1] b ∇ and the following is executed: f¨1 2 3 Three lines will display, 1 digit per line. In APLX the order is 1 2 3. Is there any APL2 guarantee the order the digits will be displayed? This can be critical if the…
Paul Houle
  • 735
  • 9
  • 17
0
votes
1 answer

Why create surrounding "neighborhoods" when using APL to iterate through the initial N by N game of life

It seems that adding extra live and dead cells changes how the original "neighborhood" would progress through the generations. When I apply the game of life rules to the initial N by N array, I get much different results going thru the generations…
0
votes
1 answer

Using Key operator to make a game but need more tree depth to create a more complex tree

I am working on a game using the Key operator to create simple parent tree nodes connected with children. Like (1 3 2 7 11 12) with 1 as a parent node and 3 2 7 11 12 children. The array has all the information via Key to create the nested array.…
creatural
  • 31
  • 4