« first day (832 days earlier)      last day (703 days later) » 

04:27
I got it working. This generates the primes < 200, in order: (0<)#&1<{x|(p=!n)+n#~!p:*&~x}/:2>!n:200
 
4 hours later…
ngn
ngn
07:58
@jordancurve nice. also works in ngn/k with small modifications
@jordancurve lots of opportunities for optimization - e.g. you can punch holes in the sieve starting from p*p instead of p and you can stop the loop when p*p reaches n
it may be better to generate a list of indices and amend (@[x;i;:;1]) the sieve instead of using x|
the initial sieve could be n# of the pattern generated by the first few primes, e.g. for 2 3 5 the pattern is 010000010001010001010001000001b. (needs amendment for the first few elements to make sure 2 3 5 themselves are treated as primes)
the sieve could represent only odd numbers with 2 as a special case
 
1 hour later…
09:36
@ngn mind if I add this to my wiki?
09:55
your aplcart link for idioms should search for 'idiom' not 'fast'
( @Razetime )
 
4 hours later…
ngn
ngn
13:50
@Razetime i don't mind, of course, but it's really @jordancurve's work
and if your wiki is about efficiency, it may be better to include a version with at least some of the optimizations i mentioned above
@ngn yes I will try
14:26
@ngn what is (3\6901) doing here?
ngn
ngn
@Razetime it's a golfed version of the first three rows of pascal's triange (a flattened 3x3 matrix)
yeah but why is it giving
(1 1 1 2 2 2 1 1
 1 1 0 1 1 0 1 1)
in the function?
ngn
ngn
@Razetime should be just 1 0 0 1 1 0 1 2 1
nono i mean along with the rest of the function
@Razetime it's being indexed
14:32
i don't get it
what's happening is like (3\6901)(0 1 2;3 4 5), like APLs (3⊥⍣¯1⊢6901)[↑(0 1 2)(3 4 5)]
ngn
ngn
^yes, thanks dzaima
oh wow
that's how indexing works
ngn
ngn
indexing is right-recursive. i think this is the most natural way to define it, given we don't distinguish between a matrix and a vector of vectors
ah, now it makes slightly more sense
ngn
ngn
14:39
each row of that matrix corresponds to a ternary digit of n-1
so like basically given two stranded arrays K will auto index into left using right
ngn
ngn
@Razetime wdym by stranded arrays? generally k has no stranding like apl, as x y is indexing - more like ⍺[⍵] than ⍺⍵
nothing it's just my convoluted explanation of what you just said
ngn
ngn
0 1 <- btw, space-separated sequences of numbers like this are considered a single token, so this is not 0[1]
yeah i do understand that
ngn
ngn
14:47
@Razetime are you familiar with that technique for computing the cell at i,j from sierpinski's triangle from the bits of i and j?
i remember seeing it ones(don't remember it well)
ngn
ngn
this expression is doing the same but for "tripinski's" triangle, so it uses ternary digits
and it computes a whole row of the triangle, so j ranges from 0 to i
f:"RGB"{3!-n-:/+/x*/(3\6901)(3*3\n-1)+3\!n:#x}"RGB"?
                                              "RGB"? Determine indices of each character in "RGB"
       {                                     } run function:
                                         n:#x  set n to string length
                                        !      range 0..n-1
                                      3\       convert to base 3 matrix
                             3*3\n-1           n-1 in base 3
                            (       )          index using this into:
i hope this is about right?
i pieced it together using oK docs(JohnE you're a lifesaver)
ngn
ngn
@Razetime sounds right except this part n-:/ - "negate n times", i.e. multiply by (-1)^n
oh so that's what it is
hm couldn't find where :/ was
ngn
ngn
14:54
yeah, -: is the monadic version of -
n monad/ x generally means apply monad n times
I thought : was put before an operator to infer it as monadic
ngn
ngn
after, not before
ok,after
ngn
ngn
: is the most special character in k. when put after a verb, it forces it to be monadic. after an adverb, it's just another adverb (one of the very few digraphs in k), after an identifier, it's assignment
neat, we have our first explanation on the wiki!
14:58
is the order of the + correct? like (1 2 3)(0 1)+2 does (1 2 3)@2 3, not (1 2)+2
@ngn yeah k in general feels like it packs a lot more versatility into its symbols
ngn
ngn
@coltim yeah, (1 2 3)(0 1)+2 should be the same as (1 2 3)[(0 1)+2]
oh ok I should fix that
ngn
ngn
@coltim thanks, i hadn't noticed that
@ngn so if I want to explicitly show indexing there's always square brackets
ngn
ngn
15:02
i suspect someone reading this might have more general questions like what does pascal's triangle have to do with this problem :)
or why do we negate the result from every other row
yes, I am adding more to the explanation(including your quote)
Honestly I should take a few hours to fully understand the reasoning before trying to write any more
ngn
ngn
15:20
@Razetime if you haven't yet, see this and a few messages after it
15:44
@ngn is ngn/k also available via nix? I just saw that kona can be used on repl.it because it is packaged on nix
I forked the fortran example: replit.com/@ichigoberry/kona
@ngn That was very helpful. thank you.
ngn/k is the default k interpreter on repl.it afaik
@Razetime oh, I did not know, when I was looking for k I did not find a repl but maybe the drop-down autocomplete box isn't autocompleting 1-letter languages
huh.
replit.com/languages/k is 404ing for me
oh it was his apl
15:50
ah!
yes, apl on replit is ngn/apl
clang-7 exists on repl.it so it should be buildable
ngn
ngn
@tosh nixos.org ? what do i have to do to make it available?
as far as I understand how it works is that there is a git repo with build instructions and once there are build instructions then the package exists (?) but I am not very familiar with package managers nor with build instructions unfortunately, let me see if i find the kona one
I think this is what needs to exist for a package: github.com/NixOS/nixpkgs/blob/…
as far as I understand nix is a cross platform package manager that has a concept of reproducible builds and some compute platforms like replit are using it
would also be interesting to have oK and BQN et al in there, I think there is a package for J
16:19
oK is mainly useful as a reference implementation at this point. It trailblazed, but ngn/k is largely compatible and more mature, I think.
 
2 hours later…
ngn
ngn
18:21
@tosh these guys have unresolved pull requests from 2016, wow :)
oh my XD
over 100k closed, jeez
wow 2,6k open PRs
lots of prs
might be semi-automated hopefully

« first day (832 days earlier)      last day (703 days later) »