APLcart is a searchable idiom collection database — snippets of code that you can search for with a “how do I achieve X” type question. I’ve not seen this for languages outside the Iverson family, but it could be equally useful for other languages, too. Note that it’s accessible from within Dyalog apl as a user command: ]aplcart
> I’ve not seen this for languages outside the Iverson family, but it could be equally useful for other languages, too.
The closest thing would probably be Rosetta Code. Iversonian languages seem to be relatively unique in their rejection of defined functions in favor of composition of language primitives, so it seems that libraries are reached for before idiomatic expressions in other langs. It seems like an algorithm dictionary in plaintext or pseudocode would be a great boon for all.
I had this same thought. The downside would probably be that you have a much much smaller set of open codebases to crib from and (for me) inevitable bugs will be way harder to spot.
If you know an authoritative source of information on a subject, for God's sake don't ask ChatGPT on the hope it will find it too, parrot it back, because it has a high probability of putting unrelated but plausible-sounding shit in there. Leaving you to sort out what's real and what's statistically-related nonsense.
Only one data point but I asked a question to my boss and he sent me a GPT reply (which he's starting to do rather too much these days) which was very incomplete at best, possibly outright wrong but also very misleading even if it was right. It certainly read authoritatively, caveat emptor.
What makes you say it was cribbed from there? The APLCart explanation is "Are all major cells of Y identical?" and the ChatGPT explanation I got from the prompt "can you explain this APL program to me" is:
----
----
Certainly! Let's break down the APL program (1=≢∘∪)Y step by step.
First, let's focus on the function ≢∘∪. The symbol ∘ is called the "composition" operator, which means it takes two functions and returns a new function that applies the second function to the result of the first function. In this case, ≢ and ∪ are the two functions being composed.
≢ is the "tally" or "count" function, which returns the number of items in an array. For example, ≢ 'Hello' would return 5.
∪ is the "unique" function, which removes duplicates from an array. For example, ∪ 1 2 3 3 4 would return 1 2 3 4.
So, ≢∘∪ means "count the number of unique items in the array". For example, if Y is 1 2 3 3 4, then ≢∘∪ Y would return 4, because there are 4 unique items in the array.
Now, let's look at the entire program: (1=≢∘∪)Y
The parentheses are used to group the functions together, so that they are treated as a single function.
1= compares the result of ≢∘∪ Y to 1. If the result is equal to 1, then 1= returns 1 (true). Otherwise, it returns 0 (false).
So the entire program (1=≢∘∪)Y means "return true if there is only one unique item in the array Y, and false otherwise".
----
----
That doesn't seem like a crib from the APLCart sentence at all. And this explanation is correct as far as it goes - it just doesn't go far enough to mention "major cells" (i.e. it would deduplicate the rows of a 2D matrix, not the individual elements). And it doesn't mention parentheses around the pattern (constant function function) is significant and makes a 'train' but then neither does the APLCart one.
16 comments
[ 2.9 ms ] story [ 78.1 ms ] threadThe closest thing would probably be Rosetta Code. Iversonian languages seem to be relatively unique in their rejection of defined functions in favor of composition of language primitives, so it seems that libraries are reached for before idiomatic expressions in other langs. It seems like an algorithm dictionary in plaintext or pseudocode would be a great boon for all.
https://shakti.com/ [1] https://en.wikipedia.org/wiki/K_(programming_language)?wprov...
[2] https://shakti.com/
I took one of the idioms and posted it into ChatGPT:
It gave me an extremely helpful breakdown, and its analysis matched the description on APLcart.If you know an authoritative source of information on a subject, for God's sake don't ask ChatGPT on the hope it will find it too, parrot it back, because it has a high probability of putting unrelated but plausible-sounding shit in there. Leaving you to sort out what's real and what's statistically-related nonsense.
---- ----
Certainly! Let's break down the APL program (1=≢∘∪)Y step by step.
First, let's focus on the function ≢∘∪. The symbol ∘ is called the "composition" operator, which means it takes two functions and returns a new function that applies the second function to the result of the first function. In this case, ≢ and ∪ are the two functions being composed.
≢ is the "tally" or "count" function, which returns the number of items in an array. For example, ≢ 'Hello' would return 5.
∪ is the "unique" function, which removes duplicates from an array. For example, ∪ 1 2 3 3 4 would return 1 2 3 4.
So, ≢∘∪ means "count the number of unique items in the array". For example, if Y is 1 2 3 3 4, then ≢∘∪ Y would return 4, because there are 4 unique items in the array.
Now, let's look at the entire program: (1=≢∘∪)Y
The parentheses are used to group the functions together, so that they are treated as a single function.
1= compares the result of ≢∘∪ Y to 1. If the result is equal to 1, then 1= returns 1 (true). Otherwise, it returns 0 (false).
So the entire program (1=≢∘∪)Y means "return true if there is only one unique item in the array Y, and false otherwise".
---- ----
That doesn't seem like a crib from the APLCart sentence at all. And this explanation is correct as far as it goes - it just doesn't go far enough to mention "major cells" (i.e. it would deduplicate the rows of a 2D matrix, not the individual elements). And it doesn't mention parentheses around the pattern (constant function function) is significant and makes a 'train' but then neither does the APLCart one.