« first day (451 days earlier)      last day (2500 days later) » 

08:50
0
Q: Creating a vector of closures in Dyalog

Ian MartinI would like to define a vector of anonymous functions that take a single parameter, then map a parameter x across this vector, returning an array of the results of f(x) for each index. Is this possible in Dyalog? I ask because my naive attempt at creating such a closure vector: fs ← {⍵×2} {⍵×4...

 
3 hours later…
12:10
Dyalog APL doesn't directly support arrays of functions, but you can get close using an array of namespaces containing functions. For example:
nss←⎕NS¨'' '' ''
nss.⎕FX ⍉∘⍪¨'f←{⍵×2}' 'f←{⍵×4}' 'f←{2+⍵×3}'
nss.f 11
22 44 35
@MortenKromberg you may want to post it as an answer there, as I have done
just expand on it a bit and use proper formatting :)
also...wow, ⍉+⎕FX
@EriktheOutgolfer Thanks, done. Well, the reason for the ⍉ is that ⎕FX expects a matrix, and we only have one line of code. So ⍉⍪ to turn each character vector into a 1-row matrix. A bit ugly, but it works.
@MortenKromberg btw I think that you can also do something along the lines of (⊢⍴⍨1,⍴) instead of that ugliness because we're not going for terseness there ;)
or even {(1,⍴⍵)⍴⍵}
Or
nss.⍎ 'f←{⍵×2}' 'f←{⍵×4}' 'f←{2+⍵×3}'
"Duh"...
@MortenKromberg hm, you may be able to avoid that redundant f← too :)
like, (⊂'f←'),¨'{⍵×2}' '{⍵×4}' '{2+⍵×3}'
12:27
Sure, or even a wee bit simpler:
nss.⍎'f←'∘,¨'{⍵×2}' '{⍵×4}' '{2+⍵×3}'
... but I am not *sure* I find that more readable.
@MortenKromberg sure, if we go towards golfing it a tad bit :P
Off to mow the lawn... may be back later :)
@EriktheOutgolfer I view that as a simplification rather than a shortening.
@MortenKromberg ...opinions :)
what I'm thinking of is that OP might want to call those functions something longer
 
9 hours later…
21:14
@JackHenahan Equivalent in ⎕ML≤1, yes. Using ⍤`, no. Just subtract less than 1 from the axis. This notation is more precise as you are really inserting a new axis before axis 1:
⎕←↑[1](1 2 3 4)(5 6 7 8)(9 10 11 12)
@Adám
INDEX ERROR
@Adám the bot can't see that edit...
⎕←↑[0.5](1 2 3 4)(5 6 7 8)(9 10 11 12)
@Adám
1 5  9
2 6 10
3 7 11
4 8 12
@EriktheOutgolfer I know, I meant to enter a new statement.
21:47
uh, there are no unanswered questions over SO rn...
 
2 hours later…
23:29
0
Q: Extract Particular Word and Geo-code it

Adarsha MurthyI have two dataframes with two columns each event: column names --> "District" "City" villages: column names --> "District" "Village" "event" dataframe has district names and events happening in its district villages. The "City" column is a sentance data which has village names of correspon...

@Adám Thanks for looking into it. I guess I'll just have to get used to it, in that case. Just feels weird, especially when ⍤ is ostensibly used in place of index notation. Oh, well :)
@JackHenahan I also thought that replaces bracket-axis, but it really doesn't. It instead provides a neat and generalised way to "pair up" the cell-sizes of argument(s) and function, something that the bracket axis can't do as well on dyadic function application, and not at all on application of user defined functions.
Ah, that makes sense, I suppose. I keep coming back to APL, and I think this time it'll stick. Now I just have to convince my coworkers :D
@JackHenahan :-) APL is only a bit over half a century old. Its prime time has yet to come, but I do believe the world is slowly getting ready. We also have a few things to fix up before show time… Let me know if I (or Dyalog) can be of help with anything.

« first day (451 days earlier)      last day (2500 days later) »