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

4:27 AM
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
7:58 AM
@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…
9:36 AM
@ngn mind if I add this to my wiki?
 
9:55 AM
your aplcart link for idioms should search for 'idiom' not 'fast'
( @Razetime )
 
 
4 hours later…
ngn
1:50 PM
@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
 
2:26 PM
@ngn what is (3\6901) doing here?
 
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
@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
 
2:32 PM
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
^yes, thanks dzaima
 
oh wow
that's how indexing works
 
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
2:39 PM
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
@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
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
2:47 PM
@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
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
@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
2:54 PM
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
after, not before
 
ok,after
 
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!
 
2:58 PM
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
@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
@coltim thanks, i hadn't noticed that
 
@ngn so if I want to explicitly show indexing there's always square brackets
 
ngn
3:02 PM
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
3:20 PM
@Razetime if you haven't yet, see this and a few messages after it
 
3:44 PM
@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
 
3:50 PM
ah!
yes, apl on replit is ngn/apl
 
clang-7 exists on repl.it so it should be buildable
 
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
 
4:19 PM
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
6:21 PM
@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) »