« first day (759 days earlier)      last day (1882 days later) » 

1:21 PM
What do you think about "functional selective specification"? I just added this to iv:
A←3 3⍴⍳9 ⋄ A[{⍺[2]>⍺[1]}]←0 ⋄ A
A←10×3 3⍴⍳9 ⋄ A[{(⍵>30)^⍵<60}]←0 ⋄ A
The function is given in the index specification (brackets). It receives the index vector on the left and the scalar value on the right for each element. If it returns 1, it selects, for 0 or empty it does not.
The difference to other methods is, that it may decide on the indexes as well as on the value.
 
1:33 PM
@ktye the ¨iness of that doesn't feel very APLy, but if speed isn't much of a concern, it seems useful
reminds me that the way works on higher dimension arrays is pretty inefficient. how about a built-in like {A←⍳⍵ ⋄ {⍵⊃¨A}¨⍳≢⍵}? almost like k's ! but the vectors items shapes are
 
1:50 PM
@dzaima Is that specially for nested arrays? what should it do?
 
@ktye the function is executed separately for every item of the array is what I'm saying
 
ngn
2:11 PM
@ktye do you know about @‌​?
 
@ngn Yes, but it is hard to remember because it has so many meanings. I think the proposed method is easier to understand and can work on both, the indexes and the values.
 
ngn
(b@i)a is like {a←⍵ ⋄ a[i]←b ⋄ a}. @ also works when i is a function (but a[{...}]←b, of course, doesn't) and it applies i to whole arrays (it doesn't do "each")
 
@dzaima with that (e.g. as ϼ) the 1st example would be 0@{</ϼ⍴⍵} 3 3⍴⍳9
 
ngn
dyalog's @ doesn't supply the indices as but they are easy to generate with ⍳⍴⍵
 
This is also a warm up for table-selection. I'm currently thinking how to do this. Maybe: T←⍉`X`Y#(⍳10;10-⍳10;)
T[{X>3};`Y] +← 1
In the row selection function, X would be initialized with the X column value.
I'm sure you think this is too iterative.
 
ngn
2:31 PM
@ktye do you (plan to) have ("where")? this could be T.Y[⍸T.X>3]+←1. i'm not sure which looks prettier, but ⍸T.X>3 should be faster than {X>3}¨
 
@ngn I do have ⍸ for normal arrays. I could extend it for tables, but the syntax would be T[⍸T[;X]>3;Y]+←1. This seems too verbose. (Where are the backticks?)
 
ngn
@ktye markdown uses them for monospaced text, you can use a \ to escape them
@ktye you don't need for tables in this case - i assume T[;`X] is a normal array
you just need modified assignment for tables
 
@ngn Currently this is returns a table with column X only
 
ngn
ah... that seems wrong to me
 
@ngn And T[;`X`Y]? Should that be a table or a two column matrix?
 
ngn
2:43 PM
i would say a matrix but i could be wrong
 
@ngn To get the array, you have to flip back and index: (⍉T[;`X])[`X]. Not very elegant.
Other topic: I included some plotting functionality (and images) into lui:
lui -i '⌼?2 3 100⍴1J1'
If your terminal supports sixel (xterm, mintty) it plots directly into the terminal.
 
ngn
@ktye in k dict[`a`b] returns a matrix (list of lists) and `a`b#dict filters the given columns
example (i don't have tables in ngn/k yet, so i used normal dicts)
 
@ngn But you do have dicts? I thought just int64.
 
ngn
@ktye int64 is my only numeric type
i also have chars and partially implemented float64s (if that's what they are called), generic lists, dicts, and many kinds of functions as first-class data
 
@ngn maybe there should be a general table-to-matrix conversion. Then it could be ok to return sub-tables.
 
ngn
2:54 PM
@ktye . h
 
nice. But I can't use it. It's dyadic. I already didn't work for indexing into objects.
I already reserved ⌶ for type-of (monadic) and type-conversion (dyadic). As I don't plan to implement all i-beam functions, I thought I could recycle the symbol.
The symbol can also be seen as an encode-decode pair, that's why I think it fits for convert.
 
ngn
3:12 PM
@ktye so, = + . hehe, i never thought of that :)
@ktye what will type-of return? ints or symbols?
 
@ngn currently it's only for debugging and returns a string of the underlying type defined in go. E.g.: apl.Int
@ngn convert can take a prototype on the left, that is any value of the target type, or a string abbrevation, but this is not done yet. `img ⌶ (int-array) currently convert to image.
 
4:11 PM
I set myself the challenge of generating primitive Pythagorean triples in APL and I'm confused on how to proceed
Given m>n, where m and n are coprime and of different parity, a=m**2-n**2, b=2*m*n, c=m**2+n**2 make a primitive Pythagorean triple
And I'm not sure how to do the filtering for coprime m and n, the filtering for different parities, and the (a,b,c) generation all in one line ⍨
Or if I shouldn't try to do it in one line as usual
 
ngn
@Sherlock9 coprime: 1=m∨n, different parity: 2|m+n
@Sherlock9 filter: boolmask/vector
 
4:28 PM
⎕←((2×/⊢),-/,+/)(2*⍨⊢)3 2
 
@Sherlock9
36 5 13
 
Close but no cigar
Oh the 2 doesn't do anything. For goodness' sake
 
@Sherlock9 1) *∘2 2) I don't think extracting it is worth it, and i find a simple dfn to be easier to read
hmm should (-/×⍨ ⋄ 2××/ ⋄ +/×⍨) be a valid way to rewrite {(-/⍵*2)(2××/⍵)(+/⍵*2)}?
 
Oh that's what you mean. I'd been trying to work with , concatenate and a two-argument dfn and failing
I'd gotten up to {(2×⍵×⍺,+/,-/)2*⍨⍵,⍺}
 
4:44 PM
@dzaima on the other hand, the current (very much unintended) state of in parens seems useful too
currently it seems (I really don't know lol) that (a ⋄ b ⋄ c)((a) (b) (c)) for arbitrary variables or length
 
4:59 PM
I've almost finished the filtering
⎕←(0 0)~⍨(⊢×((2|1++/)⍱(1≠∨/))¨),∘.,⍨⍳6
 
@Sherlock9
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│0 0│1 2│0 0│1 4│0 0│1 6│2 1│0 0│2 3│0 0│2 5│0 0│0 0│3 2│0 0│3 4│0 0│0 0│4 1│0 0│4 3│0 0│4 5│0 0│0 0│5 2│0 0│5 4│0 0│5 6│6 1│0 0│0 0│0 0│6 5│0 0│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
 
But the removal of (0 0) doesn't work
 
@Sherlock9 (0 0)(⊂0 0)
 
@dzaima Thank you and thank you @ngn
 
though really you want (((2|1++/)⍱(1≠∨/))¨{⍺/⍵}⊢),∘.,⍨⍳6 (with the gross {⍺/⍵} because of schizophrenia)
also your code doesn't check m>n
 
5:07 PM
Yep I noticed
⎕←{(-/⍵*2)(2××/⍵)(+/⍵*2)}¨(⊂0 0)~⍨(⊢×((2|1++/)⍱(1≠∨/))¨),∘.,⍨⍳6
 
@Sherlock9
┌──────┬────────┬─────────┬─────┬────────┬─────────┬───────┬────────┬───────┬───────┬────────┬────────┬───────┬─────────┬────────┬────────┐
│¯3 4 5│¯15 8 17│¯35 12 37│3 4 5│¯5 12 13│¯21 20 29│5 12 13│¯7 24 25│15 8 17│7 24 25│¯9 40 41│21 20 29│9 40 41│¯11 60 61│35 12 37│11 60 61│
└──────┴────────┴─────────┴─────┴────────┴─────────┴───────┴────────┴───────┴───────┴────────┴────────┴───────┴─────────┴────────┴────────┘
 
⎕←(⊢×((≤/)⍱(2|1++/)⍱(1≠∨/))¨),∘.,⍨⍳6
 
@Sherlock9
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│0 0│0 0│0 0│0 0│0 0│0 0│0 0│0 0│0 0│0 0│0 0│0 0│3 1│0 0│0 0│0 0│0 0│0 0│0 0│4 2│0 0│0 0│0 0│0 0│5 1│0 0│5 3│0 0│0 0│0 0│0 0│6 2│6 3│6 4│0 0│0 0│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
 
But I ran into a bug
⎕←{(-/⍵*2)(2××/⍵)(+/⍵*2)}¨(⊂0 0)~⍨(⊢×((≤/)⍱(2|+/)⍲(1=∨/))¨),∘.,⍨⍳6
 
@Sherlock9
┌─────┬───────┬───────┬───────┬────────┬───────┬────────┬────────┐
│3 4 5│5 12 13│15 8 17│7 24 25│21 20 29│9 40 41│35 12 37│11 60 61│
└─────┴───────┴───────┴───────┴────────┴───────┴────────┴────────┘
 
5:11 PM
This however finally does it :D
 
I'd write the filtering as (((2|+/¨)∧(1=∨/¨)∧>/¨){⍺/⍵}⊢),⍳6 6
 
Ahhhh
The trouble is that I'd gotten it into my head that ∧ was only LCM
 
in my APL with that new ϼ thing the expression is beautiful pretty-much-¨-less code
 
Oh man. That is pretty
Oh! I get the {⍺/⍵} thing now
 
@dzaima what is ϼ doing?
 
5:24 PM
@ktye it's like ⍳arr, but giving a vector of arrays instead of array of vectors (⍴array being the argument)
aka it's this
 
⎕←{(-/⍵*2)(2××/⍵)(+/⍵*2)}¨(((2|+/¨)∧(1=∨/¨)∧>/¨){⍺/⍵}⊢),⍳10 10
 
@Sherlock9
┌─────┬───────┬───────┬───────┬────────┬───────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬────────┬──────────┬────────┬────────┬──────────┬─────────┬─────────┬──────────┬──────────┐
│3 4 5│5 12 13│15 8 17│7 24 25│21 20 29│9 40 41│35 12 37│11 60 61│45 28 53│33 56 65│13 84 85│63 16 65│55 48 73│39 80 89│15 112 113│77 36 85│65 72 97│17 144 145│99 20 101│91 60 109│51 140 149│19 180 181│
└─────┴───────┴───────┴───────┴────────┴───────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴────────┴──────────┴────────┴────────┴──────────┴─────────┴─────────┴
 
@dzaima Thanks again!
 
6:34 PM
huh thought that special-casing power-of-2 ⍺s for `|` on integer ⍵ would wreck performance because of constant checking of non-integer ⍵s but this isn't that bad at all
https://tio.run/##SyzI0U2pSszMTfz/P9TPPyDE09czytWFy07B0MDAQOFR39SMkszc1EMrFIwf9W551NWkZFTzqHczSNJAievRlJ5HUxrIQmvornEC0LlNBnrGZmaW5oam5oYKuZk5OZnFEEFTYwtDSzMzC1RBU0tzUyCJEAQaMYVc@7fQXeMMvNGoZ6g9gDFJaTSaGBoaWliYGJqhxJilqbmRgZkxqpilsbm5oZHJQMYiBVHIlV8AjLrMqtQUGmfKAcuRBqZGJuYmBqbIsWZgYmhuZmxoaYIiaGxhZmFoYWxIhagczY3UzpBGFubmRhYWKBnSxNDU2MACWI6iCloYmRoZGFoM3XL1/38A
should really add int arrs, but that'd introduce constant overflow checking :|
 
 
1 hour later…
ngn
7:39 PM
@ktye fyi, i just tested {h:`a`b!(0 1;2 3);h.b+:1;h}0 in k4 - in this case it doesn't modify h, it creates a global instead :O ouch
 
@ngn isn't there a special function for table updates in K? Or is that only q? ![t;c;b;a]
 
ngn
@ktye i don't know about tetradic !. there's @[a;i;:;b] for a[i]:b
 
ngn
@[a;i;:;b] returns a new object without modifying a. @[`a;i;:;b] modifies a
@ktye thanks. must read
 
is there a simple way to tokenize a simple expression? I've got this but it feels pretty hacky
(i find myself way too often doing 1@1 for of )
 
ngn
8:13 PM
@dzaima there's 200⌶, it's a bit clunky
 
@ngn the expression isn't necessarily going to be valid APL nor tokenized in Dyalog sadly
 
ngn
@dzaima ⎕r then?
(or equivalent)
@dzaima ok, maybe this was a silly answer. what language are you tokenizing and in what language?
 
@ngn that'd require me adding regex to my APL and this doesn't feel more APLy at all
@ngn all that the tokenization has to do is separate sequences of ⎕A,⎕D from + and -, preferably without using any irreplaceable features of Dyalog and my APL (so porting to one or other is simple for comparison)
 
ngn
@dzaima do you have dyadic ?
 
@ngn I'm in the middle of writing it :)
 
ngn
8:24 PM
 
what if of had an implicit 1 added to (requiring it to be 1 shorter than )?
I could also support both (≢⍺)≡≢⍵ and (1+≢⍺)≡≢⍵ but that'd be pretty strange
 
@Adám is there a way to use nuget with dyalog?
or nuget packages in general?
 
ngn
@dzaima requiring or allowing off-by-1 lengths isn't in the spirit of array programming
 
@ngn having edge-cases doesn't feel in spirit too (as in that the only time an item of isn't in the output of is from leading zeroes)
 
ngn
@dzaima well... depends on how you look at it
 
8:37 PM
what's better - requiring adding 1, or 1@⎕IO for half the uses or requiring off-by-1 length arguments?
 
ngn
in k intlist_y ("cut", similar to apl's ⍺⊂⍵) is a generalisation of intatom_y ("drop", like apl's ⍺↓⍵)
 
@ngn could i see some usage of that?
 
ngn
i can't argue about uses, but i can argue it's consistent
 
@ngn as i have no idea what that is or what to do with intlist_y i just want any input→output example :|
 
ngn
intlist is a list of indices where the array should be cut, as if with scissors (apl uses a boolean mask). the slice after each cut point is included in the result
in k the length of intlist matches the length of the result. in apl the length of must match the length of
 
8:49 PM
@ngn ah okay, if i understood that correctly, yes it does seem consistent
 
ngn
this is also consistent with how ⍺⍸⍵ (interval index) works - it considers anything before the first "point" to be (loosely speaking) indexed at ⎕io-1 - outside the array
 
but for a split with a boolean vector this feels pretty consistent and imo consistency > in-spirit
 
ngn
@dzaima reminds me of with an even stencil size
 
@ngn most of the reason i haven't added stencil is the extremely strange way that works
imo 1, is way less "in-spirit" than off-by-1 argument lengths
 
ngn
@dzaima i like the way you used 2 in the mask to produce an empty slice in the result :)
do you have ⍸⍵ ("where") with repetitions?
 
9:00 PM
@ngn yeah
 
ngn
so what are the starting indices of 0 1 2 0 0 1⊂'abcdefg' (assuming ⎕io←0)? if you included an initial 1 in the mask, you could say "it's just ⍸⍺"
 
@ngn ⎕IO doesn't matter for that split
but yeah
 
ngn
ah right, ⎕io doesn't matter
 
on that topic - should i change the default ⎕IO to 0 (at least for non-REPL)?
 
ngn
@dzaima i have a strong opinion about that :) it should be only 0
 
9:09 PM
@ngn I can agree that there aren't "use-cases" for ⎕IO←1 but to say that it shouldn't exist is a different question
 
ngn
@dzaima define "shouldn't". for me "slows down execution and makes my impl more complicated" ≡ "it shouldn't exist"
even if it's a tiny slow-down
 
i wonder if the jvm would do things like inlining the IO and removing the pointless +0
 
ngn
unlikely
 
@ngn really my apl wasn't meant to be for speed but for usability, it just really got off-track. can agree on that it complicates the implementation though
 
ngn
another argument against ⎕io is: it makes debugging harder, as it could have different values at different levels of the stack
 
9:19 PM
well my apl doesn't have debugging :p
 
ngn
even if it's ⎕← debugging, you still have to pay attention to what ⎕io is
 
and any same-name variable could have different values on the stack
 
ngn
@dzaima true, but they don't sneakily affect how most primitives behave
 
@ngn imo ⎕IO should, at worst, be the same in a codebase, and at best, only be 1 in the REPL
another argument against ⎕IO is that libraries might output in a different ⎕IO than the parent environment
 
ngn
@dzaima aplCode.replace("⍸", "{⍵⌿⍳⍵}"); problem solved :)
 
9:34 PM
@ngn is better on smaller inputs though
like what's so bad here? I've removed the +sc.IO, negative check, extracted the unchanging values and it's still slower :|
does the jvm actually manage to optimize or ?
 
ngn
@dzaima could you paste your new code?
 
@ngn code; replacing .sum with a manual loop didn't help either
 
ngn
@dzaima you seem to have implicit conversions between doubles and ints
why not declare v as int? also: sub[p++] = i might benefit from a hoisted double version of i
(i'm not sure if any of this matters, just guessing)
 
9:50 PM
@dzaima inlining the expression makes it faster for all of ⍳¨50×⍳50 :|
@ngn that indeed made it faster :D
 
ngn
@dzaima nice :) btw, shouldn't you be using long instead of int?
 
@ngn java arrays can only be indexed by an integer so longs would be pointless
 
ngn
oops, i forgot that
 
imma just assume a cosmic ray hit my ram and move on
 
10:14 PM
so if i do go with that, should i just replace the regular ?
 
ngn
@dzaima define "should" :) any incompatibility with the dominant apl vendor distances your language from its potential user base
 
@ngn well / already is split up, and my apl isn't supposed to replace Dyalog
my apls target user base is me :p
 

« first day (759 days earlier)      last day (1882 days later) »