⍣ with a function right operand is conceptually simple, but has some gotchas to be aware of.
For this lesson, we'll call the left operand f and the right operand g, that is, we're applying f⍣g.
When the derived function is used dyadically, it is just as if it was used monadically with the left argument bound to f. That is, X f⍣g Y is exactly the same as X∘f⍣g Y, so we only need to discuss the monadic case.
The high-level view is that f⍣g applies funtilf g ⊢
Now, what exactly does that mean?
We start by applying f Y and its result is used as left argument to g. The right argument to g is the original Y.
g must then return 0 or 1.
If g returns 1 it means we're done, and the result will be the newly found value, f Y.
If g returns 0 then we conceptually set Y←f Y and start over.
@JeffZeitlin So your code has two issues. There's your lack of ⍺⍺, but also remember that the left argument stays constant, and the right argument is updated.
You also don't have to use both arguments of g. Often, you just want to repeat an action until a condition on the generated value is fulfilled.
@all Task: Use ⍣ to find the first power of 2 larger than 100. That is, double 1 until it exceeds 100.
Remember that the newly generated value (the one we're interested in) is the left argument of g.
If you use the right argument of g, you'll have applied f one more time than needed because your stop condition hinges on the previous value, but the current value has already advanced one more step.
Any takers? You'll need a user defined function (you probably want to go with a dfn or a train) as g.
Oh, that looks like a standard dfn, then, so (2×⍣{100<⍺}1) - we use ⍺ instead of ⍵ because - like you said - if we use the right argument, we'll go once too often.
I have to write a program with c# to find the printers which have same logos over netbios protocol
The printers are in different subnets and they are netbios enabled
They have been connected with each other by workgroup network
Is there any special API for this aim?
So here, 1↓⍣{IsPal ⍺} is the same as what we've done before, but we only apply it if the argument isn't already a palindrome. The "if" is expressed with ⍣ and an array right-operand.
@JPeroutek Ah yes, sorry. I misread there. Of course, you're free to answer in another APL. I often outgolf existing APL+WIN solutions. And you can still get upvotes, just not that bounty.
Python 3, 388 398 408 409 415 417 493 bytes
To make it more accurate, increase n
from random import*
u=uniform
c=lambda A,B,C:(C[1]-A[1])*(B[0]-A[0])>(B[1]-A[1])*(C[0]-A[0])
I=lambda A,B,C,D:c(A,C,D)!=c(B,C,D)and c(A,B,C)!=c(A,B,D)
def a(l,v,n=9**6,s=0):
g=lambda i:(min(x[i]for x in v),max...
I made the approximate python solution, but I was looking to make an exact APL solution
I'll show you a trick using f⍣g. Sometimes, we can have a nested list of lists of lists, e.g. because we got some JSON data, but we really want to use APL's array capabilities, so we want to convert this to a proper multi-dimensional array. Any ideas?
So ↑⍣≡ is a neat idiomatic expression. Remember it.
@all Challenge: The other way, converting a high-rank array to lists of lists isn't as neat, because you can keep applying ↓ and it will just add more nesting. What can we come up with for that?
So, for 2 3 4⍴⍳24 we want to get ((1 2 3 4) (5 6 7 8) (9 10 11 12)) ((13 14 15 16) (17 18 19 20) (21 22 23 24))
OK, that works, too, and probably is the better way to handle it; I was thinking that we'd revisit the palindrome problem, and replace ↓ with a similar function to IsPal