« first day (267 days earlier)   

1:48 AM
-1
Q: Problems when trying to use arrays in APL. What have I missed?

HarleyI first added some indentation before the log below to make the posting tool happy. Then I was told to add some context to explain the code section, but that context is now already in the code section, because I added indentation as I was told. Please look for questions that are interleaved with...

 
 
10 hours later…
11:50 AM
'Morning everyone o/ Hey @Adám, are you working on the WPA golf challenge?
 
@J.Salle No. I had a look, but I'm not going to read long RFC to know what to do. IMHO, the OP should contain everything necessary to solve the problem.
 
@Adám Yeah, I'm gonna comment something along those lines. Challenge is too language-restrictive, IMO
 
@J.Salle It isn't really language restrictive. It just uses complex algorithms which few languages have built-ins for. It would be more interesting if the OP prohibited built-ins for the main pieces.
 
@Adám my point exactly. Every golflang I know would have to create a SHA-1 algorithm, then build an HMAC function using that and then implement a solution to the challenge, it's just too convoluted
 
12:15 PM
@Adám would f←{⍵=3∧⍵=19:doSomething⋄⍵} work as a function? I want to doSomething unless the input is either 3 or 19, in which case I just want to print the input.
 
Ven
Now that I have the mind cleared, I remember why I generated 10 "steps" instead of 9: I'm stupid and I misunderstood how interval index works :D.I'm making good progress again.
 
@J.Salle Yes, but remember APL's order of execution: Functions are right-associative, so the leftmost = sees 3∧⍵=19 as its right argument. Either use parentheses or use .
@Ven Great to hear!
 
@Adám how would I use ? f←{(3∧19)∊⍵:doSomething⋄⍵}?
 
@J.Salle f←{⍵∊3 19:doSomething⋄⍵}
is "member of"
 
Oh okay, so the ∧ is not needed at all? Nice. Thanks!
 
12:23 PM
@J.Salle Correct. You only need if you have several very different conditions.
 
And can I nest those conditionals, or I'd need another function? doSomething would have to check whether the argument is a prime or not.
I'm thinking f←{⍵∊3 19:(⍵∊<primes>:doSomethingElse⋄returnSomething)⋄⍵}
 
@J.Salle You can write multiple conditions with {(cond1)∧(cond2)∧cond3:true⋄false} but note that all conditional expressions will be evaluated.
@J.Salle You would have to use {} not () and you have to supply the argument(s) to the inner function as well.
{⍵∊3 19:{⍵∊<primes>:doSomethingElse⋄returnSomething}⍵⋄⍵}
 
@Adám I see! Thanks, I think I've got what I need now
 

« first day (267 days earlier)