« first day (1259 days earlier)      last day (1403 days later) » 

1:01 AM
1
Q: Implement 1-dimensional version of Multi-Take

BubblerBackground Adám and I were once discussing a way to properly extend some features in Dyalog APL. I came up with the following extension to Take, a function that takes some front or back elements (and an analogous extension to Drop). We agreed that it was a good idea, but it was incredibly hard to...

 
 
6 hours later…
RGS
6:47 AM
@Adám today is informal-conversation-because-of-no-apl-cultivation day, right? At what time? I'm asking again because a fortnight ago you said one time and started 1h earlier :-P
 
7:12 AM
@RGS Such difficult questions. Yes, it is a conversation day today, scheduled for 16:30 our time.
 
7:24 AM
@Feeds @Bubbler For the actual implementation, it might make most sense to limit each element to maximum 2 elements, no?
 
@Adám That's fine, I guess. (mostly since all possible outputs will be covered by the 2-number cases)
 
RGS
@Adám Ok, thank you :)
 
@Bubbler Exactly, and it makes the documentation simpler too (There can be at most one non-negative number and at most one non-positive number).
 
7:42 AM
Makes sense.
 
 
4 hours later…
11:55 AM
Hello, I have a TradFN and I have two results I want to pass out. One of them being optional(shy) and the other always needs passing out. How can I achieve this? I've tried various combinations of { } and ( ) around my results but not found a solution just yet.
 
@TomCockram I'm not sure what you're envisioning. Are you trying to achieve conditional shyness or a two-element result?
 
RGS
@Adám feels like Tom wants the tradfn to either return 1 or 2 results, depending on context
 
@Adám Perhaps I've got my terminology confused. I want a two elemt result with one of those being optional
 
RGS
@TomCockram can't you return a 1 or 2 element vector and then the calling code has the responsibility of checking the length of the returned value
 
@TomCockram When you return a 1-element result, do you want to return that as a vector or a scalar?
 
12:03 PM
@RGS I suppose I could although the two sets of data I'm passing out are very different. One is a matrix and one is vector.
 
@TomCockram (Yeah, a "shy" result is one that is returned, but not displayed even if unused. E.g. a←42 returns 42 but doesn't display it.)
 
@Adám well the result I always want passed out is a matrix and the one which may or may not be passed out is a vector of elements. Ah yes I don't mean shy then, I mean optional.
 
RGS
@TomCockram but you can still enclose both and return them in a vector, no? Or just enclose one and return it; then the calling code can use ≢ to check if you just got 1 of the return values or the 2 of them
 
@TomCockram What's wrong with some code like:
∇ res←Fn arg
  :If condition
    res←mat
  :Else
    res←mat vec
  :EndIf
∇
 
RGS
@Adám is this equivalent to what I was saying? this looks more or less like an implementation of what I described :)
except I would probably do res ← ⊂mat
 
12:08 PM
@RGS This doesn't enclose the "single result case"
 
RGS
@Adám yeah I noticed; how would you then distinguish the two cases outside of Fn?
 
@RGS By the rank (or depth).
 
@RGS @Adám the main source of data I'm passing out is a matrix and this other result may or may not be empty based on if we have a mismatch in data. I wanted to keep them split into different vars but I guess I could just pass them out as you've done above and then split them outside of this function?
 
RGS
@Adám but this only works because in this case we are dealing with a matrix and a vector, right? in a more general setting enclosing the single result would be a good idea, no?
 
@TomCockram Well, if you don't consistently pass out a 2-element vector, then the receiving function wouldn't be able to split them anyway. E.g. (always optional)←MyFn arg would fail when returning only one result.
@RGS Yes.
@TomCockram Is there any problem with returning the empty element for consistency? What value does the out function use instead of the missing one?
 
12:13 PM
@Adám yes and this is the problem I have. I wanted to make it something like {optional } always ← Myfn arg
 
RGS
@Adám ofc I have no idea of what the actual context is but returning mat ⍬ in the 1-result case looks elegant
 
@TomCockram But again, what would the outer function's code look like?
 
@Adám the outer function will email if this optional elment has something in it. But the emailing only happens at the end and I want to collect a list of things to email rather than sending lots of emails.
 
@TomCockram Uh, you didn't answer my question. Can you give me the syntax you envision the calling function to use when calling the inner function and using its result?
 
@Adám erm not sure I understand but this is the line of code that produces my optional result and basically I will catenate this onto an email later on: warning←(unqiuelist(~∊)data[;pos])/unique
pos is the position of a certain header in the matrix I want
 
12:22 PM
@TomCockram Since you asked about how to define a function, I imagine that you want to call this function from somewhere. Is that correct?
 
@Adám yes this bit of code lives in a function that I call and then the result of what I showed may get passed out.
 
@TomCockram Right. I'm interested in the caller's code.
 
@TomCockram in the result braces don't signify whether something is optional (as in it may not be returned), but whether something is shy (as in it doesn't get printed out by default in a REPL, which is unrelated to your problem). Your best choice is to choose some form of outputting a single array with both outputs and destructuring it after the function has been called
 
RGS
@TomCockram if I understand correctly, Adám wants to see how you will handle the ambiguity of the 1- or 2-element return result after calling your function, not how you produce the results
 
@RGS thanks, didn't quite understand @Adám well I haven't worked on that part because I haven't got the result out yet. I think I can just rework it so that I don't need to worry about optional results or anything. Thanks for your help
 
12:32 PM
@TomCockram Ah, that explains it. My father taught me the practice of writing the code "top-down". If you had written the outer function first, you would never have wanted for your inner function to return a variable number of results (whatever that may mean).
 
@Adám Good advice. I suspect there is a much simpler way to do what I'm trying to do. Probably spaghetti code :D thanks for your help people. Is there a way I can "save" this section of the chat so I can refer to it later if needed
 
@TomCockram You can bookmark the first (or any) message: Hover over the target message, click on the down-pointing arrow head, then click "permalink". A new window/tab will open and you can copy the URL from there.
 
 
1 hour later…
2:00 PM
@Adám @RGS went away and came back to it and realized i was over complicating it. I created a function of it's own and based on the results I assign it different things and then later on I'll choose to use it or not depending upon the shape.
 
RGS
@TomCockram Ok great!
 
@TomCockram Good to hear.
 
2:18 PM
Announcement: Dyalog '20 is going digital. The competition winner can present online, but will also be invited to Dyalog '21 (Olhão, Portugal).
 
RGS
@Adám Oh, so glad you kept it in Pt; I thought you were going to skip coming to Portugal
 
Is the video call now or in an hour?
 
RGS
@Marshall scheduled for an hour from now but Adám has a history of starting them now... so we'll see :)
 
If it was always at the scheduled time, the it wouldn't be informal, would it now?
 
2:33 PM
It's not formal unless you can prove that it happened in Coq.
2
 
RGS
@Marshall I know a friend who might have a go at that
@Adám It's not that I am bothered by it starting around now, it is a much more pleasant time than 16h30
 
3:29 PM
Announcement: Informal meetup in a minute! Password is the result of +/2 7 3 5 in APL/J/K
 
4:07 PM
Sorry @all, having a lot of trouble with my computer
 
RGS
4:21 PM
with all the food puns going on I don't understand why I didn't remember this earlier, but do you guys know what I had for lunch a couple of times when I was studying in The Netherlands..? pancakes with, you guessed it, apl and bqn!
 
4:38 PM
I don’t think it worked... is anyone else still able to use the room?
 
@AviFS i believe everyone just left
 
@RGS +<-1 (On phone; computer charger broken)
 
yay reference & Marshalls compiler run with LEB128
 
5:21 PM
@Adám Any success?
 
@Wezl Never tried… I didn't record today's. Not really interesting other than when participating.
 
 
2 hours later…
7:22 PM
The result of (<1 2) ,&> 3 4 7 is 3 3 $ 1 2 3 1 2 4 1 2 7. It appears that <1 2 is being cyclically extended to the same length as the right arg 3 4 7 and then the concatenation is being done element-wise, but I'm not sure. I would like to know what precisely is happening and (if possible) where in the J dictionary the relevant rule is described. Try it online!
 
7:33 PM
@Adám did I miss it?
 
7:49 PM
@matt Yes.
@Jonah Look at the composition chart, and follow the sequence:
Split into cells: <1 2 vs 3 and 4 and 7
Apply > to each cell: 1 2 vs 3 and 4 and 7
Apply , to each result cell: 1 2,3 and 1 2,4 and 1 2,7
Collect results: >1 2 3;1 2 4;1 2 7
Result: 3 3 $ 1 2 3 1 2 4 1 2 7
@Jonah The only piece missing here is the pairing of the single cell on the left with each cell on the right. This is the fundamental mapping rule of APL/J where 1+2 3 4 works as 1 1 1+2 3 4 or (1+2),(1+3),(1+4). Makes sense?
 
@Adám Perfectly. I understood all the pieces but wasn't seeing how they came together here.
 
8:46 PM
@dzaima Nice! I just moved all the specs and docs as well as dzaima+reference over to # comments instead of , so that's another little thing to do. But it has the added bonus that #!s don't need special handling any more.
 
@Marshall yeah, shebangs are another nice thing with # as comments
(i was updating the app readme, and wanted to include android instructions, but that's not that nice without a keyboard, so now i'm stuck making that. At least the file is editable & testable all from the app :D)
 
 
2 hours later…
11:04 PM
Found a neat property: for a permutation vector V, (⌽@x y⍋V) ≡ (⍋⌽@(∊∘x y)V), i.e. swapping two numbers is equivalent to swapping that two positions in the inverse permutation.
 

« first day (1259 days earlier)      last day (1403 days later) »