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 test for string input? (Dyalog APL)

I was working on this function Happy to practice control flow. Happy tests if a number is a happy number. I was trying also to learn error handling. So, I tried to catch if a user input is anything other than an integer. Especially if the input is a…
zeynel
  • 177
  • 1
  • 1
  • 12
1
vote
4 answers

How can I do this operation without parens?

Here I read that "The Babylonians came up with the "quarter-square multiplication", which reduces multiplication to subtraction: a*b = (a+b)^2/4 - (a-b)^2/4 When I tried this in APL I ended up with this: (((a + b) * 2) ÷ 4) - (((a - b) * 2) ÷…
zeynel
  • 177
  • 1
  • 1
  • 12
1
vote
1 answer

What are these enclosed box characters?

When you enclose something it's in this little box. Sometimes there are these symbols making up the box. Arrows, broken lines, tildes, epsilons. What do they mean
Ikura
  • 75
  • 3
1
vote
1 answer

Length error while creating a dfn function in APL to check for anagrams

I am a beginner in APL and am writing a dfm function to check whether two strings are an anagram of one another. The method I thought of was: {⍵[⍋⍵] ≡ ⍺[⍋⍺]} However, it returns 0 for 'ALBERT EINSTEIN' and 'TEN ELITE BRAINS' that are anagrams. I…
okty
  • 11
  • 2
1
vote
1 answer

Time testing a Dyalog Idiom on large array

For this first row found idiom (w∘{(↓⍺)⍳↓⍵}) there seems no reduction in search time even though the first search would be hashing the array making later searches much faster? w← 100000000 3⍴'123' w←w,[1]'321' z← ⎕AI[3] ⋄…
Joe Killian
  • 149
  • 4
1
vote
2 answers

Function for first match in a nested array

What is the best way to search a nested array like this for the first appearance of 2 2 2 in each vector? Are there special functions in APL to avoid searching the entire vector? ?10/¨10⍴2 (1 1 2 2 1 1 2 1 1 2) (1 2 1 2 1 1 1 1 1 1) (1 2 1 2 2 2 2…
Joe Killian
  • 149
  • 4
1
vote
2 answers

APL - Import dll

I'm going to take a chance here and see if anyone can help me. I'm making use of a simulation package written in APL. I need to do some machine learning on data and would like to make use of existing libraries available for C++ and compile into a…
ceds
  • 2,097
  • 5
  • 32
  • 50
1
vote
2 answers

How can I count the number of occurences of a scalar in a vector, in APL

For example I have a vector 'H2DH2DH', is there a way to count the number of 'H' scalars that appear?
1
vote
1 answer

APL: how to search for a value's index in a matrix

In APL, matrices and vectors are used to hold data. I was wondering if there was a way to search within a matrix for a given value, and have that values index returned. For example, say I have the following 2-dimensional matrices: VALUES ← 1 2 3 4 5…
z.rubi
  • 327
  • 2
  • 15
1
vote
1 answer

APL Poker Game Scoring

I have a problem in APL which involves getting values and scoring them like a poker game. So I used CHARS⍸CAR3 5 29 30 8 29 23 5 34 34 33 2 34 3 34 6 10 10 15 6 15 15 Which is an integer representation of characters in "deck" of…
1
vote
1 answer

Iterating over a List from an imported (.net) class in Dyalog APL v14.0 and up

I'm a complete newbie when it comes to APL, and I hope some of you fine folks might be able to help me... I have a class library written in C# and exported to a dll. I then import this class in Dyalog APL (v14.0) and I am able to instantiate objects…
1
vote
2 answers

Reduce by two with named function

I'm using GNU APL. Also, I'm not really sure what the correct name for this is, but the basic idea is that I have a list of things and I want to do something with each pair. It's complex, so I've made a function for it. I notice that this works: …
Daniel Lyons
  • 22,421
  • 2
  • 50
  • 77
1
vote
2 answers

APL code to unpack date converted to day count via Gregorian rules

I'm interested in APL code to unpack a date packed to an integer day count using Gregorian calendar rules. I asked a question a month or so ago for APL code to pack a date so I could calculate the count of days between dates (Convert date to day…
Paul Houle
  • 735
  • 9
  • 17
1
vote
2 answers

Convert date (year month day) to day count

I would like a function (using Gregorian calendar rules) given 3⍴⎕TS would return 1+ the number of days since 1 1 1. EG if the function were named X: X¨ (1 1 1) (1 12 31) (2 12 31) (3 12 31) (4 12 31) 1 365 730 1095 1461 I need this so I can…
Paul Houle
  • 735
  • 9
  • 17
1
vote
1 answer

APL i-beam function

I'm re-learning APL from the Gilman and Rose book. There are references to the i-beam functions to retrieve user information and the like, but I noticed they are not referenced in the APLX documentation which is more contemporary. Have they been…