« first day (736 days earlier)      last day (799 days later) » 
00:00 - 20:0020:00 - 00:00

12:21 AM
@ngn @nathanrogers imo pad (i$) should do this (depending on how you define null for padding purposes)
 
 
2 hours later…
2:22 AM
@ngn what is your ultimate vision for ngn k?
 
 
3 hours later…
5:30 AM
@chrispsn What does this mean?
 
@nathanrogers ngn/k and several others have the 'pad' primitive:
ngn/k, (c) 2019-2021 ngn, GNU AGPLv3 - git.sr.ht/~ngn/k/blob/master/LICENSE
 4$"hi"
"hi  "
 
What do you mean "depending on how you define null for padding"
 
oh - most ks have int null as 0N while k9 has 0
if pad (a) worked for int lists and (b) was 0N then 4$1 2 would be 1 2 0N 0N which is not useful for you unless you fill it later
but if k9 still had pad it'd generate 1 2 0 0 for the same operation
 
so I have a list of strings
I want to pad an empty string at the end of the list so they're all uniform in length
 {{-5#("";""),x}@" "\x}'d
that seems to do ok
 
+|+|'
li2021.03.08 4gb 2cpu (c)shakti 2.0
 ++("hi";"world";"")
hi
world

 #'++("hi";"world";"")
5 5 5
 
5:37 AM
hey, that'd be clever, I'm prepending though
so what, reverse flip flip reverse? seems heavy
 
ah whoops i edited instead of posting. yeah, could try +|+|'
 
doesn't look like that does it in ngn?
("kk";"OR";"kv";"->";"kw")
("NOT";"cvc";"->-";"cwc")
("klk";"AND";"krk";"->-";"ktk")
("iu";"OR";"jf";"->";"jg")
("ata";"AND";"aza";"->-";"bbb")
("jpjpjp";"RSHIFT";"222222";"->->->";"jqjqjq")
("ivi";"AND";"jbj";"->-";"jdj")
yeah has a lot of undesirable effects
{-5#("";"")," "\x} that seems to work ok
 
that's a k9 thing. flip behaves differently in ngn/k
k9 also lets you do {(-|/#'x)#'x}
that is, negative take pads. and for right-pad you just over-index
 
ok, trying to do a lookup
I know for a fact its in the list, but I keep getting 0 from this
+/~^(,"a")?v
,"a" is in v
I see it
"au"
"da"
"kz"
,"a"
"iz"
"lu"
its right there
 
try v?,"a"
 
5:45 AM
that returns whether ,"a" is in v, but I want the index
&~^(,"a")?v
really aiming for that
 
hmm, it should give the index
what is v?
oh right, see above
 
the problem is probably that it's looking for the "a" atom, not the enlisted version
 
no
the problem is it isn't finding anything
I did "kz"?v
its right there
but &~^"kz"?v returns !0
??
 
try (`$v)?`a
that is, use symbols instead of strings
 
5:48 AM
how do I get type info?
 
@
 
@v ←→ `A
`C ←→ @'v
 
backtick-A is ngn's generic list type, i guess
list of strings is a generic list
 
well, I'm out of ideas
its right there
 
ngn
@nathanrogers world domination
 
5:50 AM
@nathanrogers did you try the 'using symbols' example above?
 
'dom
@ngn I kinda was hoping for a real answer. Do you plan to take it beyond the spec, or leave it as the spec but provide extensions, or do you plan for people to hook in and modify it on their own... what's the plan
@ngn also, can you help with this?
some of v is
"kz"
 ,"a"
 "iz"
 "lu"
 "js"
 "az"
 "jf"
&~^(,"a")?v
returns !0
?
 
it works for me: ngn.bitbucket.io/k/…
 
d: day 7
p:{-5#("";"")," "\x}
pd: p'd
(x;f;y;v):(+pd)0 1 2 4
&~^(,"a")?v
that's all of it, I'm not doing anything hokey
 
or you could use match: ngn.bitbucket.io/k/…
 
d is just lines from a file, split on space, ensure that all lengths are 5, split them up in to variables
@chrispsn that's great thanks
 
5:55 AM
with 'searching for the list itself, not each atom in the list' problems like this, it can often be easier to use symbols instead of strings
since symbols are atomic
 
that's fine, its just text from a file anyway
 
ngn
@nathanrogers initially i just wanted to make a free, albeit slower, imitation of k5, and maybe attract developers and have an ecosystem for building something like a libre kOS. but then shakti appeared and arthur made k9 radically different from its predecessors. most developers naturally followed him and his new language.
i imagine if i integrate ngn/k with something (a graphics library, a web server, more crypto, etc..) it could be a useful base for building applications in a simple, pleasant vector language. but there's no specific plan. i just enjoy implementing languages.
 
@ngn This is what I want
I'd be happy to contribute some J labs type stuff, maybe write some stupid simple tutorial scripts to help out scrubs like me
I want to figure out how to help because I'm not an implementor, I don't have the domain knowledge for array programming or C tooling or parsing... but I want to help
@ngn quick question, how can I tell if something is a number
 
ngn
@nathanrogers thanks for your readiness to help. there's plenty of work around an implementation, as you became painfully aware from my lack of docs. in order to help, one doesn't have to be a c programmer.
 
I just don't know what things are, so I don't know how to handle documentation either, I'm sat here wondering why my ? lookup won't work, and how to check if something is a number :O
and I guess I technically don't need to know if its a number
so I'll skip it
 
ngn
6:07 AM
@nathanrogers @x should return one of `b`h`i`l (byte, short, int, long - 8, 16, 32, 64bit). eventually i'm gonna merge these into a single user-facing int type.
 
oh, ok
 
ngn
so: |/`b`h`i`l=@x
 
is there an equivalient to

x = NonFalsey || DefaultValue
 
ngn
@nathanrogers x:$[NonFalsey;NonFalsey;DefaultValue]
 
damn, that's not going to look nice
 
ngn
6:11 AM
@nathanrogers maybe or:{$[x;x;y]} and then or[NonFalsey;DefaultValue] if you use that often?
 
what is the context? do you need the full generality of 'non-falsey' or can you get away with a specific case (eg length zero)?
 
@ngn its going inside a nasty double recursion thing
how do I check against !0?
&x~\:y
in something like this
 
what do you do afterwards?
 
ngn
@nathanrogers you want to test if a given vector is empty?
 
maybe append the default? *(&x~\:y),3
 
6:13 AM
@chrispsn so, I'm doing some kind of node lookup in a table, if it isn't found, I need to return the value as an int, so I guess I don't need the branching thing anyway
@ngn yea
I guess * would work
 
ngn
@nathanrogers ~#x
 
yeah *!0 gives 0N
all these nulls everywhere is really a nuissance
 
ngn
@nathanrogers would 0s be better, like in k9?
 
I don't know what K9 is, and I don't know what would be better
I just think that having nulls in the language is kind of annoying
I like in APL not having to worry about checking or filtering nulls
 
k9 is Arthur Whitney's new k dialect
 
6:17 AM
@chrispsn what i mean to say, I don't know what k9 does differently
 
ngn
@nathanrogers nulls represent missing data. the idea is that you can fill them with whatever you want. but in practice most often that's just 0.
 
@ngn I'd honestly prefer the APL method
at least that's useful
 
it pads with zero
 1 2 @ !5
1 2 0 0 0
 
ngn
@nathanrogers apl doesn't support out-of-bounds indexing, though
 
what in gods name is THAT
 
ngn
6:19 AM
for instance
 "abc" 1 2 0 2 5
"bcac "
the " " is a null because 5 is not in !#"abc", i.e. it's not a valid index
@nathanrogers chrispsn's example shows how it works in k9. the three zeroes at the end are the result of out-of-bounds indexing
"outdexing" :)
 
"how long is too long"... this program seems right to me, but its taking forever
and I have no idea what its doing
 
ngn
6:34 AM
@nathanrogers can you show the program?
 
\l 15t.k
d: day 7
p:{-5#("";"")," "\x}
pd: p'd
(x;f;y;v):(+pd)0 1 2 4
(⍸):{&x~\:y}
s:,"a"

{$[#l:*pd v⍸x; ((l 4);(l 1);(o l 2);(o l 0)) ; x]} s
so the base case is really when x is a number, its not going to be in v, so it should just return itself
 
ngn
((l 4);(l 1);(o l 2);(o l 0)) <- the parentheses around individual elements are redundant
(l 4;l 1;o l 2;o l 0)
@nathanrogers - nice :) but i think it's more like apl's dyadic (without underbar)
 
is there a replace?
@ngn you're right, I just wanted something temporary to shorten the long line
 
ngn
@nathanrogers replace a character in a string? "b"/"a"\x
works for substrings of length >1 too
 
ok, this is getting annoying
why the fuck are there \r characters in my text file
I just edited it with vim
 
ngn
6:44 AM
@nathanrogers is :set ff=unix in your .vimrc?
oh, you mean vscode inserted the \r and you used vim to fix it..
 
no I mean I copied and pasted from the website the base case
I have now edited the file manually several times
and its still reading in
in vim in linux
searching the document no \r
 
ngn
@nathanrogers i don't think you can search for it when it's part of the line ending
but strangely searching for \n works
 
\l 15t.k
d: day 7.1
p:{-5#("";"")," "\x}
pd: p'd
(x;f;y;v):(+pd)0 1 2 4
(⍸):{&x~\:y}
s:,"d"

{$[#l: *pd v⍸ \x; (l 4),":",(l 1),"[",(o l 2),";",(o l 0),"]" ; x]} s
this works for the base case
but when I run it on the input, it just runs and runs and rusn
{...}@'v
"x:[123;]"
"y:[456;]"
"d:AND[y:[456;];x:[123;]]"
"e:OR[y:[456;];x:[123;]]"
"f:LSHIFT[2;x:[123;]]"
"g:RSHIFT[2;y:[456;]]"
"h:NOT[x:[123;];]"
"i:NOT[y:[456;];]")
I guess I don't wnat brackets when its a number
I just want x:n or y:n
so I'll need a new branch, yay
 
ngn
is d just 0: of the input?
it prints something instantly when i run it
 
I'll commit what I have
its fixed now
pushed
 
ngn
6:55 AM
pulled
 
please don't solve it for me
 
ngn
ok
 
just a pointer as to why it might be infinite
or if my input has some kind of recursive nodes
i don't really know how to debug much in K
 
ngn
i get this when i try to run it:
'cpl
x:[123;]
  ^
 
how to do nested conditions?
oh,
get rid of the leading .
 
ngn
7:00 AM
@nathanrogers $[a;b;c;d;e] is cond, it means "if a then b else if c then d else e"
or, of course you can nest explicitly: $[a;b;$[c;d;e]]
@nathanrogers without the . it prints some stuff and ultimately:
("x:[123;]"
 "y:[456;]"
 "d:AND[y:[456;];x:[123;]]"
 "e:OR[y:[456;];x:[123;]]"
 "f:LSHIFT[2;x:[123;]]"
 "g:RSHIFT[2;y:[456;]]"
 "h:NOT[x:[123;];]"
 "i:NOT[y:[456;];]")
 
right
 
ngn
and it's instant
 
I'm not handling ints yet
so change the day from 7.1 to 7
 
ngn
ok
 
7.1 is the base case I was using to test
 
ngn
7:03 AM
ok, now it's in an infinite loop, it seems
 
I have to get to bed, and I'm just making a mess over here...
the base case is that its an int, return the int
maybe I just need to swap the conditions
I just thought that returning x if not found in the table would suffice
I got all day tomorrow, so I'll try then
 
ngn
i'll investigate
 
 
6 hours later…
1:19 PM
@ngn is this intended? expected just one 'hi'
ngn/k, (c) 2019-2021 ngn, GNU AGPLv3 - git.sr.ht/~ngn/k/blob/master/LICENSE
 (#:)#("";"hi")
("hi"
 "hi")
 
ngn
@chrispsn i'm still hesitating :)
it's nice to have {n}# as "replicate"
 
ahh so you've moved away from having (f)# as filter
in which situations does the number of times you need to replicate depend on a property of the data you're replicating?
 
ngn
the presence of { }_ suggests the result from { }# should be treated as boolean too but we don't have another concise way to express replication
@chrispsn replicate is more general than filter
@chrispsn probably very few
@chrispsn any better ideas than {n}# ?
 
maybe & and indexing in?
what can't & do that replicate can?
 
ngn
@chrispsn it's just shorter
 
1:27 PM
feels like another case where a domain adverb would help (perhaps with a little primitive reshuffling)
 
ngn
 {y@&y :'x}[3]"abcd" /one way to do it
"aaabbbcccddd"
@chrispsn what would it look like with "domain"?
 
well 'where' might be the domain-ified version of x replicating itself
or rather, x#^x with ^ the domain adverb and x the usual input to where
 
ngn
tbh, part of the reason i want "replicate" is i don't want to break this answer :)
it uses ..{6}#{3}#'{2}#''..
 
i also like 'dict-where' for this kind of thing, if it feels better than indexing
&"ab"!2 3 => "aabbb"
 
ngn
@chrispsn i don't understand this. how does ^ apply #? what does it give it on the left and on the right?
 
1:42 PM
@ngn ^ would mark the verb as 'apply this verb to the domain of x instead of x itself'
though whether that's consistent with the original proposal...
 
ngn
@chrispsn ok, here's an example: &3 2, the result should be 0 0 0 1 1. we have x:3 2. its domain is 0 1.
to produce something similar to the result, ^ must act like "each" and apply x[0]#0 and x[1]#1, i.e. 3#0 and 2#1
 
right, so & might give 3 3 3 2 2 there and &^ might give 0 0 0 1 1
 
ngn
but then it would have to raze (,/)
@chrispsn why should & give 3 3 3 2 2? is that something useful?
 
i don't know, to be honest - felt like a consistent result given & generates indices
that wasn't part of the original proposal; would need to dwell on it
 
ngn
and if &3 2 is 3 3 3 2 2, then when we apply & to the domain 0 1, the result should be ,1
 
1:58 PM
i just ran &^3 2 using the old test script and it gave ,2 which i guess makes sense for some defn of this adverb
 
ngn
ah, so it applies & to the domain, and then indexes the range with the result
 
in this case it literally did &x!!#x
might want a 'dictify list' verb to go with it
anyway - needs further thinking
i just liked how it achieved the properties in the 'tl;dr' at the top of the doc
gotta go
 
 
2 hours later…
4:12 PM
what is 'stk?
@bakul do you know what 'stk error is?
@dzaima do you know how I can coerce numbers from string?
`d$,"123"
,49.0 50.0 51.0
I'm getting this kind of shit
 
4:31 PM
@nathanrogers don't know what's the proper way. `j?"123" and ."123" work, but are quite overkill. $ is definitely not what you want here
 
.[.;x;,]
I'm trying something like this
but its erroring when x is a numer, and not erroring when its a string? idk wtf roflmao
I just want, if its a number, to know that its a number
`i~@ .[.;x;,]
this isn't doing it
`i~@ is integer matches type of..., so clearly I'm still not evaluating the numbers correctly
 
@nathanrogers 'stk is "stack" (generally from recursing too much)
 
@nathanrogers {$[|/`b`h`i`l=@x;x;. x]}
 
@nathanrogers I'm not sure how it's handled in ngn/k but in e.g. k4 there's separate LHS args for strings ("I"$"123" returns 123i versus "i"$"123" returning 49 50 51i)
 
@dzaima tat doesn't do coersion
 
4:41 PM
@nathanrogers do you want . or .: here?
 
I get rank error with .:
 
@nathanrogers well what do you want it to do then
 
I want it to do .[. ; x ; :]
give me .x if its not an error, otherwise the error string
 
@nathanrogers with .[.:;x;,]?
 
yes I get a rank error
.[.:;"123";,]
("r"
"n"
"k"
"\0"
0)
 
4:43 PM
@coltim .[.:;"123";,] errors
 
@dzaima this is my problem with your solution
{$[|/`b`h`i`l=@x;x;. x]} "x"
(""
""
,"x"
,"x"
,"x"
,"y"
""
"")
idk what that is
 
@nathanrogers me neither. I just get 'val
and what'd you expect it to do other than throw an error
 
my lord, `i~@123 doesn't even work
what am I even doing
k is "consistent" ?
what is `b?
 
11 hours ago, by ngn
@nathanrogers @x should return one of `b`h`i`l (byte, short, int, long - 8, 16, 32, 64bit). eventually i'm gonna merge these into a single user-facing int type.
 
@nathanrogers I think part of this may be from .: being more like "evaluate" than "parse string to number". so . x does a lookup in the global namespace of a variable named x, which apparently was already defined in your session (versus not in @dzaima's)
 
4:49 PM
i:{.[{|/`b`h`i`l=@.x};x;0]}

i "123"
0
 
@nathanrogers oh yeah, you probably just have an object named x somewhere ^^^
 
@nathanrogers is your input always going to be a string? (or character?)
 
yes
i'm reading from file
and I need to know if the thing I'm looking at is a number
 
@nathanrogers oh, figured it out - you want i:{.[{|/`b`h`i`l=@.x};,x;0]}
 
...........hwy
 
4:52 PM
@nathanrogers the 2nd arg of . is the list of arguments
 
right, but ."123" works
 
@nathanrogers .[.;"123";0] is calling .["1","2","3"] whereas you want .["123"]
just as .[+;1 2;0] is calling +[1;2]
 
oh
lame
 
what about {(`c~_@x)&/(x>47)&x<58}
 
@dzaima thanks for figuring that out
 
4:55 PM
(I assume the "real" solution is to prod @ngn to implement a "parse-number-from-string" overload =P)
3
 
I really don't know how to troubleshoot k
aside from just guessing, I tried printing out .[{ \x};x;0]
but I didn't understand what I was looking at
 
@nathanrogers I just looked at the examples given in \+ :)
 
so did I
 
@nathanrogers .[+;1 2;{x}] -> 3 pretty clearly isn't evaluating +1 2 to get 3
 
no but + by itself is dyadic
 
4:58 PM
@nathanrogers but it still shows that the 2nd item is the argument list
(fwiw i barely know k, i'm learning pretty much everything as i go. this is good practice :p (and preparation for a dzaima/k maybe in the future))
 
so .[f; argsList; err] checks if f . argsList errors
(versus f[argsList])
@dzaima could this fail if there happens to be a global variable already defined that happens to be an integer?
e.g. abc:1;i "abc"
 
@coltim of course, it's a horrible way to do what it does, but that's beside the point
{.[{|/`d=@`j?x};,x;0]} is somewhat better, but it allows floats too
 
5:27 PM
@ktye the [...] reminds me a bit of dc, but this might be common in stack-based languages, i don't know
@ktye what i find interesting is the source, where's the w program? it's not here github.com/ktye/i/tree/master/_
looks like (a dialect of?) k
 
5:57 PM
why does this not work?
pad:{(y*y x 0)#0
pad[<; 3]
pad[>; 3]
getting type errors
this should return 3 0's if true and !0 if false
and is a nice idiomatic, pad left pad right
but it aren't doing it
{x .y,0}[<;3] that works ok
 
@nathanrogers (y*y x 0) is parsed as y*y[x[0]]
 
@ngn how would you?
    b16   :(16#2)\
    (×:):{(x>0)-x<0} / signum
    shift :{
      pad:{(y*x .y,0)#0}
      b:b16 y
      2/((#b)*× x)#(pad[<;x]),(x_b),pad[>;x]}
this seems like a lot for 100 << 3
shift[3;100]
and -3 for righshift
basically a translation of APL from aplcart
(×∘×⍨∘≢↑↓)
 
ngn
@nathanrogers 8* ?
 
ngn
shifting left by 3 is multiplication by 8
 
6:07 PM
right
but I need logical operations?
because those are the commands I'm being given
I don't just get to pick what logical operations are
they're pretty well defined
b16   :(16#2)\
shift :{
  pad:{(y*x .y,0)#0}
  b:b16 y
  2/((#b)*× x)#(pad[<;x]),(x_b),pad[>;x]}
LSHIFT:shift
RSHIFT:{shift[-x;y]}
AND   :{2/&/b16'x,y}
OR    :{2/|/b16'x,y}
NOT   :{2/~b16 x}
 
@nathanrogers shifting at least is better implemented by multiplication and division, than binary
 
so, the 3 is the power?
what is exponent?
in k
 
@nathanrogers probably better to just cache powers of 2
 
can do */x#2
 
*\16#2
 
ngn
6:11 PM
@nathanrogers how about LSHIFT:{2/x_b16[y],&x}?
 
ngn
@dzaima that's better, works for negative shifts too
 
I don't get how its doing the index of negative..
 
@nathanrogers it does that only if the number being negated is negative
 
never mind
 shift:{$[~x .y,0; \z*po2 y;z%po2@y]}
 shift[>;3;100]
I kind of like this better
right left shift
LSHIFT:shift[<]
RSHIFT:shift[>]
well, but that's a clever solution @dzaima I like it... I'm thinking too literally
 
ngn
6:19 PM
@nathanrogers btw, in arthur's k int%int returns a float
@coltim i'll add that
 
@ngn is the old \h just removed now? i think it served a useful purpose in parallel to the new expanded docs
 
ngn
@ngn `I$ because types in ngn/k are symbols and $ accepts symbols on the left
@dzaima why 2 ways to do it?
 
shift:{$[~x .y,0; z*/y#2;z%*/y#2]}
LSHIFT:shift[<]
RSHIFT:shift[>]
no variable
 
@ngn different uses. \h is much better for quickly finding a thing and giving a general overview, \+ etc is better for learning more about the specific thing
 
@ngn I agree with dzaima the old single page made it nice to see everything at a glance
 
6:25 PM
@ngn taps sign saying (-n!x) ~ (x%n)
 
and I can drill with \+ or \'
 
ngn
@dzaima it's more than a screenful and it's hard to scroll, so you're right
 
@ngn precisely :)
(also maybe a general syntax page may be helpful, e.g. comments, strings (+ single characters), typed & generic lists, noun/verb/adverb (maybe include the grammar?), maybe the fact that {} is a noun, $, whatever else seems important)
 
ngn
@dzaima i was thinking of \0 like in kona + the 1line grammar
any ideas for how to mark implementation-specific extensions in the help?
 
@ngn isn't it all implementation-specific?
 
ngn
6:38 PM
@dzaima most of ngn/k is k5-6-compatible
 
@ngn I think having a separate comparison page would be better, listing all differences, instead of that being scattered around the docs, which you'd only use to find how to do something in ngn/k
 
ngn
i'll think about it
 
when searching for the function to get the type of an object, i certainly don't care if it differs from k5/k6. And when comparing ngn/k to k5/k6 for any reason, I don't think I'd want full docs about every builtin surrounding that info
 
k5/k6 also feel somewhat obscure, at least in terms of what the "official" version does/did
 
ngn
6:54 PM
@nathanrogers did you figure out what the problem with your was?
i can boil it down to two things: how prototypes work (e.g. why ("ab";"cde") is " " and not "") and how find works (x?y could be used instead of ) in ngn/k vs original k's "rank-sensitive" version
 
ngn
7:22 PM
should `I$"" be 0 or 0N?
 
@ngn what was my problem with ⍸?
 
ngn
@nathanrogers ^^^^
when (it should really have been ..) couldn't find the variable name in v, it returned an empty list, then you used that as index in pd and got an empty result, and * (first) of that result was not what you thought it would be - it wasn't an empty list.
 
no but the count is 0
 
ngn
oh crap.. i tried to rewrite it with "find" and forgot to change it back
 
@ngn hmm what about !0? otherwise my vote is for 0N (I like my nulls!)
 
ngn
7:36 PM
@nathanrogers so, without . it keeps recomputing the same expressions over and over again
@nathanrogers with . there's a malformed expression it tries to evaluate
@coltim should it parse a single int or multiple space-separated ints?
 
@ngn I think the former. i'd say parsing strings like this comes up most often when dealing with external data (where I'd have to imagine space-separated ints are pretty rare)
 
ngn
!0 is inconsistent then - a list coming from a function that should normally return an atom
ok, so i'll special-case the empty string to parse as 0N
0 came out naturally, as "" is like a number without digits :)
 
@ngn I guess that could also be consistent with 10/!0 =P
(but if I imagine I had a CSV and it had a numeric column but a cell is blank that having it be parsed as a null is "better")
 
ngn
yeah, real-world stuff polluting the perfection of mathematics :)
 
don't even get me started on malformed values being converted to nulls, ugh what a mess
although I wonder what the semantics would be of throwing an error when trying to parse a non-integer as an integer
 
00:00 - 20:0020:00 - 00:00

« first day (736 days earlier)      last day (799 days later) »