« first day (2578 days earlier)      last day (71 days later) » 

3:45 AM
0
Q: Merge Vectors In APL

Jay MoskUsing Dyalog APL I would like to take a Mask Vector where '-' means use the original character and any other character is to replace that position in the Data Vector. So in the example below, Mask 'a' is used on Vector 'b' to create Vector 'c'. ┌──────┬────────┬────┐ │X--Y-Z│--34--91│-+-+│ Mask V...

 
4:39 AM
How can I draw or plot a Boolean matrix as a black and white image in Dyalog APL? (I am on Linux if that's relevant.)
 
 
3 hours later…
7:12 AM
@Mukundan314 Have a look at bmprenderer — let me know if you need help using it.
 
7:32 AM
@RubenVerg No. Its author doesn't really believe in such.
@RubenVerg is "Set how much the file may hold". doesn't need further description, as it would just be a subset of the docs — afaict, there's no concise summary that would work.
 
7:56 AM
@RubenVerg Should ^ not have a note that most APLs support this too? Or should simply list all but dzaima/APL?
@RubenVerg APLX does have windowed reduces, execute, local vars, and branch.
 
@Adám, thanks, it works great!
 
8:14 AM
@RubenVerg APL2 does not support "Index Generator (Indices)"
And GNU APL has dyadic
 
 
2 hours later…
9:54 AM
@Adám ^ is already a special case because there's a dialect that doesn't support the standard. including all dialects in the special case would probably mean that all other Unicode-equivalent glyphs supported in each dialect should also appear in the list?
@Adám hm, that's an unexpected answer, not believing in documentation? weird, I guess I'll use the language bar plus some testing
 
10:36 AM
@Adám wdym "local vars"?
 
@RubenVerg ;
 
 
1 hour later…
11:56 AM
can't make it to the quest, here's my solution: (,÷∨)∘1
is there any dialect that uses ⍶⍹ for operands that also supports operator recursion? if so, what glyph does it use instead of ∇∇?
 
12:19 PM
@RubenVerg Huh, that's a good question. I don't think so.
 
1:00 PM
Welcome to APL Quest, 2023-7! Today's quest is Let’s Be Rational:
> A rational number is a number that can be expressed as the quotient of 2 integers p÷q — a numerator p and a denominator q. For example, for 1.5, p and q would be 3 and 2, respectively.
> Write a function that:
• takes a single non-zero positive number right argument.
> • returns a 2-element "integer" result representing the smallest non-zero positive values for p and q respectively
1 hour ago, by RubenVerg
can't make it to the quest, here's my solution: (,÷∨)∘1
… which looks deceptibly simply, but actually isn't.
We can use tacit.help to unpack it, giving: {(⍵,1)÷(⍵∨1)}
Here, is the Greatest Common Divisor. But what does that even mean for a non-integer?
The Greatest number you can divide e.g. 3.5 with to get an integer. But dividing 3.5 with anything, surely makes it even "less" whole‽ No, not if we divide it by a number between 0 and 1.
Indeed, it gives 0.5 and 3.5÷0.5 is 7, the first part of the desired result.
If 0.5 is one factor of 7 then the other factor has to be 1÷0.5 i.e. 2.
Maybe an easier to follow solution is the (mathematically equivalent) 1∘(∧÷,)
This expands to {(1∧⍵)÷(1,⍵)}
Here, is the Lowest Common Multiple. So we're asking for the smallest positive integer that we can get to by multiplying 3.5 with an integer. That would be 7, which is 3.5×2
The rest follows as before; divide 7 with 1 to get 7, and with 3.5 to get the denominator, 2.
If we don't like this whole business with extra divisions, would could write the longer 1∘∧(⊣,÷)⊢ or {n,⍵÷⍨n←1∧⍵}
 
1:19 PM
this feels like a problem that's somewhat hard if you don't find the trick - in this case using gcd/lcm
were there other approaches?
 
Well, even if you're not aware of the primtives, you can easily implement them. E.g. GCD←{⍵=0:|⍺ ⋄ ⍵ ∇ ⍵|⍺}
 
Sorry, I am too late
 
No worries. Welcome!
 
Thanks.
I' ll post my soluitons
1(∧,÷⍤∨)⊢
t,⊢÷⍨t←1∧⊢
@RubenVerg but I saw a very impressive one above :)
 
@RubenVerg Oh, you mean submissions in the competition? Looking at that now.
 
1:24 PM
I also made the second one which might be faster.
 
It seems the test framework doesn't properly check that the numbers are as small as possible, so a few people submitted solutions that just multiply by a huge power of 10.
(Don't worry, they were well marked down for doing so.)
No, everyone either "cheated" or used /
I do want to mention this stranded formulation, which reads nicely: {⍵ 1÷1∨⍵}
OK, here's a bonus quest or two…
What if I want this to work on non-scalar arrays of numbers?
 
using rank?!
 
So, two options: an array of the same shape, with each element becoming a 2-element vector , and yes, increasing the rank by adding a trailling (or leading!) axis.
@Richard Can you do it — well?
 
I have to take that as homework I think. Not on the fly...
can you give an example of an input?
 
1.2 3.5,÷3 should give
6 5
7 2
1 3
The nested thing is of course just 1∘(∧÷,)¨ but that's not efficient, as we could do the entire at once: 1∘(∧÷,¨)
And then with 2 2⍴1.2 3.5,÷3 4 it should give
6 5
7 2

1 3
1 4
 
1:38 PM
0.5 2 ⍴1(∧,÷⍤∨)⊢
 
That isn't general. Try it with the matrix argument.
 
yes you're right!
 
But go ahead (anyone reading this and wanting the challenge), work on this and respond, and I'll see you next week for 2023-8: Critical Thinking!
 
thanks!
p.s. just a few weeks left for our problems...
Would you mind continuing it?
And use another source for our problems?
It takes a lot of time for you so don't feel oblidged
Just appreciating the effort you are taking for it
 

« first day (2578 days earlier)      last day (71 days later) »