« first day (734 days earlier)      last day (801 days later) » 
00:00 - 22:0022:00 - 00:00

12:00 AM
right but maybe its just raw bytes
does it just default to ascii?
 
ngn
@nathanrogers you can try to send raw bytes and see how the terminal will display them
in k 0x6162 is a string equivalent to "ab"
so you can do f 1: 0x0102.. with the hex of whatever bytes you wanna send
 
neat
turns out I've only really messed with socket libraries, and not raw sockets :O
I'm looking at an old project I was working on, and apparently I was just working from an API that wraps all this behavior
:P
cool
f:<":127.0.0.1:1234"`
so how does this read?
 
ngn
@nathanrogers btw, wireshark is a great tool for learning how network protocols work, if you ever need to
 
what does the k-part mean? and is it generalized to anything else?
 
ngn
@nathanrogers well, f: is assignment. < is a monadic verb here, and the rest is a string symbol literal
 
12:06 AM
: and : have some kind of meaning
 
ngn
< is the same < that does "grade up" but it's special-cased for symbols
@nathanrogers oh, there should be a ` between < and "
`"abc" is parsed as a single token
it's not ` applied to "abc"
 
I don't know the purpose of the leading : in ":..."
 
ngn
@nathanrogers um.. legacy. i'll get rid of it :)
it's because there used to be these path symbols in k5-6: `:/path/to/file.txt which i still support
 
is : relative?
 
ngn
@nathanrogers the whole thing is a single token
 
12:11 AM
I mean is`:/path relative to anything? or absolute
 
ngn
@nathanrogers path that start with a / are absolute, others are relative
 
so now I can communicate with you exclusively through K
this is great!
just what I always wanted
I'm gonna get a server running on my raspi later
 
ngn
@nathanrogers such a chat server could be better than this one - imagine no need to escape ` and \ - what you get is what you typed :)
 
 
3 hours later…
3:32 AM
I thought that $ was the string-ification function?
{`md5"yzbqklnj",$x}'!5
{$`md5"yzbqklnj",$x}'!5
this doesn't return what I'd expect @ngn
 
what do you expect?
 
"0x860ed4ec499c3b39fa0b5a7c44b70d45"
not (,0x86;,0x0e;,0xd4;,0xec;,"I";,0x9c;,";";,"9";,0xfa;,0x0b;,"Z";,"|";,"D";,0xb7;,"\r";,"E")
apparently the length of the result of `md5 is a list
ah, `k works
but why
 
3:58 AM
@rak1507 I'm curious about performance
     s041:*&{"0x00000"~7#`k `md5"yzbqklnj",$x}'!100000
obviously this is slow as balls
a recursive solution would probably blow the stack without tail recursion
in case you're wondering what the case is, just checking for leading 0's
I can work out the code reduction myself
actually, you know what b f / 1 is probably the right way to go
let me try that
 {~"0x00000"~7#`k `md5"yzbqklnj",$x} {x+1}/1
282749
yeah that's much faster
 
nice
 
i'm gettin it
is there a way to pass arguments to this adverb?
"0x00000" {~y~(#y)#k md5"yzbqklnj",$x} {1+x}/1
I'd like to do something like that
I guess I could do something like {...}["0x00000"]
i should really spend more time before asking :/
its still super inefficient for the "0x000000" case with 6 leading 0's
what is idiomatic selection?
{x@&~4=x}1 2 3 4
filter/compress, that sort of thing
is there pattern matching in K?
I have a nested list, and I want to match the pattern

list^(anything; specific number; anything)
c^(::;4;::)
i figured something like that would do it
in APL I would want to do a column select, do a (n≠column)⌿mat
{~4=x 1}#mat is still inelegant because I need to call this for a list of n's, not just 4
{(|/2 4=\:x 1)#x}@+mat
I'm really grasping at straws now
this works for a single value n, but not for more than 1?
 
5:21 AM
@JohnE there's no "in" for ngn/k?
how do I get values by key in ="lkjasdofiuqwer"
 
(="lkjasdofiuqwer")"a"
,3
"lkjasdofiuqwer"?"a"
3
and for that matter, in oK:
in
{[x;y]~^y?x}
 
'typ
{x"a"}="a;lkjpoiuqwlh,vjn"
      ^
i guess you need @
but why
 
a function cannot conform with a charvec
 
is there pattern matching in the language?
 
no
 
5:42 AM
m_l doesn't seem to work in ngn either
 
ngn
6:13 AM
@nathanrogers $x is atomic. it penetrates to the atoms (scalars) and converts them to strings. so $"ab" should be (,"a";,"b").
@nathanrogers a list of characters, aka a string
@nathanrogers `k@ doesn't penetrate. it formats the object as a whole and always returns a single string.
 
man I can NOT do simple shit today, I'm getting irritated
f'list and it isn't working....
idkwtfbbq roflmao
 
ngn
@nathanrogers try this: {x+~&/1 1 16>3#`md5"yzbqklnj",$x}/1
 
i don't follow
 
ngn
@nathanrogers you want the first 5 hex digits of the hash to be 0s, right?
that's equivalent to having the first two chars (i.e. bytes) as 0s and the third one lesser than 16
 
so you're just checking the first 3 16 bit columns
 
ngn
6:27 AM
@nathanrogers yeh, but 8-bit columns actually
one hex digit is 4 bits
 
`i$ 0x00000f
0 0 15
but I don't get the values
oh
lowest
but still yeah I don't get the values
 
ngn
"values"?
 
1 1 16
the constants
the values, I don't get where they came from
also I don't get why ' is constantly giving me rank errors on simple lists X(
 
ngn
@nathanrogers for an unsigned byte, 1> is the same as 0=
 
oh right, ok
 
ngn
6:36 AM
@nathanrogers in the third byte we want the upper half to be 0, while the lower could be anything, so that's equivalent to 16>
@nathanrogers for example?
 
{2<+//~^"aeiou"#=x}
count vowels
this is apparently erroring when the length of each value doesn't match
idk my brain is fried I guess
I can't tell it to do things
I've been trying to figure out an idiomatic row selection based on column values for like.... 3 hours?
+/,/.~^"aeiou"#="abcdead"
that should do it yeah?
 
ngn
@nathanrogers right, your previous version would fail with a length error when there are vowels with different numbers of occurrences, e.g. "aaaee"
@nathanrogers simpler: +/~^"aeiou"?"abcdead"
 
{~/x}2':"abbdead"
can I not do a sliding window on a user function?
 
ngn
@nathanrogers the user function needs an "each"
@nathanrogers but it would be simpler to use "equals eachprior" =':"abbdead"
or "matches eachprior" if you prefer
gtg
 
6:53 AM
vc:{2<+/~^"aeiou"?x}
rp:{|/~':x}                              / repeat letters
il:{~|//~^("ab";"cd";"pq";"xy")?/:,2':x} / in naughty list
s051:{&/(vc;rp;il)@\:x}                / all true
here's something I don't understand
2015/5.txt is just a file with strings on new lines
but when I call
+/s051 'day 5
I get a rank error
but if I call +/ s051@'day5 it works just fine
I can't tell if I'm just fried and need sleep, or if I just can't make heads or tails of things today
selection, application, "spelling", iteration, its all so particular in K... idk maybe I just need some sleep
it'd really be nice if the rules were codified somewhere and not left up to tripping over yourself ever few minutes. In particular with regard to white spacing, and when user defined functions are allowed or not
 
 
3 hours later…
ngn
10:04 AM
@nathanrogers a'b is not the same as a@'b. as i've mentioned before, @ is implicit between nouns (not between a noun and an adverb).
@nathanrogers perhaps everything will click into place after you study the 1line grammar and "get it"
E:E;e|e e:nve|te| t:n|v v:tA|V n:t[E]|(E)|{E}|N
(i'd be happy to explain whatever isn't clear)
 
 
5 hours later…
3:18 PM
@ngn so am I to understand that when we say "noun"/"verb"/"adv" we are not referring to the implied values in the evaluation of an expression but the literal tokens that comprise the text of the expression?
 
3:41 PM
The literal syntax and not the value or the meaning of the syntax, correct?
syntactically

f g x ←→ function function noun

but semantically

f g x ←→ function (noun←function noun)
 
ngn
4:07 PM
@nathanrogers yes! well done for realizing it. usually i have a lot of difficulty explaining that.
@nathanrogers f and g are identifiers, and therefore nouns
the biggest gotcha is that {..} is also a noun
so, in {}=0 1 2 the verb = will take {} as left arg, and that's why we need @ to separate them
(assuming you want monadic =)
 
ngn
4:58 PM
@ktye there already is make libk.so. i'll try to separate the syscalls and main()/_start() from the rest of the code.
 
5:08 PM
@ngn I'm glad I got that clarified
I think the opposite is true for APL because it evaluates as it interprets, no?
 
ngn
@nathanrogers yes. that's what people mean when they say "apl cannot be statically parsed".
 
f/x join "ra"/("ab";"cadab";"") -> "abracadabra"
f\x split "ra"\"abracadabra" -> ("ab";"cadab";"")
f/x decode 24 60 60/1 2 3 -> 3723 2/1 1 0 1 -> 13
f\x encode 24 60 60\3723 -> 1 2 3 2\13 -> 1 1 0 1

Quick feedback, this reads f/x f\x but then shows nouns, should this b x/y x\y etc?
 
ngn
but apl uses array/function/operator terminology. confusingly, j works the same way as apl and calls them noun/verb/adverb/conjunction.
@nathanrogers good point
maybe we need a naming convention for the variables in the examples?
like i=int atom, I=int list, m=monadic function, etc
 
A array
L list
N number
I int
F float
D dict
f g h functions
x y z any type
A(n) or L(n) for list of numbers?
idk if there's a distiction between array or list?
from the kona docs I understood the core data type to be lisp style lists, idk
 
ngn
@nathanrogers at least in the world of apl, "array" is more general it could mean "atom" (i.e. "scalar") or "list" (i.e. "vector")
also note that terminology changed in k9 - a "list" there is only the generic list - (0 1;2 3) but not typed lists like 0 1 or "ab" (i think that was a bad move)
@nathanrogers why uppercase?
case could be used for the distinction between atom(lower) and list(upper)
 
5:24 PM
np
 
5:38 PM
repl can't handle multilines?
 
ngn
@nathanrogers it can't
because it's supposed to start evaluating when you press enter
 
ngn
and at that point it doesn't know if you're gonna start the next line with a space or not
 
can I do with ;?
;<return> would have to be a continued evaluation, wouldn't it?
there's nothing else it could parse to?
 
ngn
@nathanrogers ; is a statement separator
@nathanrogers in "abc;" there's an empty statement at the end
in "abc" there isn't
 
5:42 PM
you can have empty statemtns?
 
ngn
an empty statement evaluates to the only unprintable value ::. so, a trailing ; is significant.
 
:C
but in the context of the repl specifically
are you ever going to have {blah blah blah;\n
 
ngn
@nathanrogers idk, probably not
@nathanrogers if you want to use the repl as if it's an editor, why not just use an editor? :)
 
best not to introduce contextual stuff either :C
no I want to use the repl sending code from my editor to be evaluated
so I don't have to constantly use rlwrap and boomer arrow keys
 
ngn
bash has C-x C-e for multiline editing. maybe readline/rlwrap can be configured too?
@nathanrogers you don't like rlwrap??
@nathanrogers what's "boomer arrow keys"?
 
5:47 PM
ctrl+enter to send line to active terminal
highlight lines ctrl+enter sends lines
but I can't send multi lines :C
 
ngn
ah
that could be fixable
 
this is a pretty nice setup too
ctrl + enter addon, + zen mode with everything turned off, and the shakti extension in vs code with vim hotkeys
smooth
@ngn \clear was something that worked the other day, isn't working now
in fact it hangs the REPL
 
ngn
@nathanrogers i noticed a similar problem and i have a fix
let me finish what i started and i'll push to git, and then have a look at the problem with multiline
 
I suppose naming something "nil" is bad?
 
ngn
6:03 PM
@nathanrogers why?
 
isn't nil a symbol?
 
ngn
@nathanrogers it's whatever you define it to be. i don't know if official k terminology uses "nil" for anything.
 
ngn
6:45 PM
@nathanrogers this is harder than i thought. when you paste in a terminal, read() feeds me the lines one at a time.
i don't see how i can know where the paste ends without introducing something complicated like delays
 
sure
I think its probably best to keep to single lines and only format as multline if necessary for loading purposes
how do you load vs repl?
 
ngn
@nathanrogers i don't understand the question
 
@nathanrogers I use entr to rerun the entire file when it has changed (it also clears the screen and interrupts the previous run)
 
example?
entr k myfile.k
?
 
echo 18.k | entr -csr 'time k 18.k'
 
7:02 PM
hmm
not doing anything
I can run
echo 2015.k | entr -c ~/k/k 2015.k
but when I add the other 2 flags, nothing happens
s wants a single expresssion so something like
echo 2015.k | entr -sr "~/k/k 2015.k" and nothing happens
eh, works fine enough with just -c
thanks for that :)
 
7:25 PM
@copy I figured it out. vscode (even when launched and connected to wsl) does not trigger file change events
it works well from the terminal though
 
8:05 PM
@ngn nulls question, is the reaction to getting Nulls just reflexively ~^? because dealing with nulls feels like an interruption to otherwise concise expressions
what sort of common "tricks" are there for handling nulls? What are the direct use cases aside from existence or non-existence?
 
e.g. to make a projection. f:{x+y+z} has valence 3. calling f[1;2] returns a projection, which is a monadic function. f[1;;2] does the same and does not bind y. the arg list contains a nil.
But there are differences between nulls and nil. 0N is a null value of type int. it will not project.
 
ngn
@ktye ah, so "nil" is :: (when used as placeholder)?
 
8:22 PM
"1;2"+"3;4"
100 118 102
well that's odd
 
@ngn i just called it like that.
 
ngn
@nathanrogers arithmetic verbs treat chars as ints
`c$"a"+!26 /alphabet
 
but isn't that inconsistent with yesterday where I was told that "using math" on strings converts them?
it doesn't matter anyway, the format is ("1234,1234";"1234,1234")
and .' works fine
 
ngn
@nathanrogers can you link to the message in which that was said?
 
@JohnE this one @ngn
I guess it wasn't yesterday though
 
ngn
8:27 PM
@nathanrogers "coerce them to numbers" here means treat individual chars as their ascii codes, not try to parse the whole string as a number
 
oh
see, i just confuse myself
i tell you though, typing simple stuff like this and seeing the screen scrawl past will never stop being satisfying
{{(,x 1),.'x 2 4}-5#" "\x}@'day 6
("toggle 461,550 through 564,900"
"turn off 370,39 through 425,839"
"turn off 464,858 through 833,915"
"turn off 812,389 through 865,874"
"turn on 599,989 through 806,993")
(("toggle";461 550;564 900)
("off";370 39;425 839)
("off";464 858;833 915)
("off";812 389;865 874)
("on";599 989;806 993))
its just nice
 
ngn
i'm glad you like it
 
um, say I wanted the last character in x 1
'typ
{{(,*|x 1),.'x 2 4}-5#" "\x}
                   ^
oh, this is another @ problem isn't it
 
ngn
@nathanrogers - acts both as a verb and as part of numeric literals
 
actually, I was just going to ask how -'s bind
 
ngn
8:38 PM
it's disambiguated based on the preceding character, so you can just insert a space before it, no need for @
 
oh, I see. so if I wanted the inverse of the first 5 I would do - 5#!10 but if I wanted the last 5 I would say -5#!10
 
ngn
@nathanrogers -1 2 is a list of -1 and 2. - 1 2 is the negation of 1 2.
1-2 3 is 1 subtraction 2 3
1 -2 3 is a list of 1, negative 2, and positive 3
in one word, it's intuitive
and not as ugly as apl's ¯ or j's _
 
i think like so many things, its intuitive when you begin to assimilate the whole model. one bit at a time...
@ngn with the new build "\clear" gives me TERM environement variable not set
 
ngn
@nathanrogers i'll have to work on that..
 
it no longer hangs
are there any inturrupt sequences?
 
ngn
8:50 PM
i don't pass on the environment to new processes, but i should
@nathanrogers ctrl-c?
 
but that exits the repl, anything to stop an expresion if its taking a while?
 
ngn
@nathanrogers no
there are ideas for how to do it
Sep 29 '20 at 21:36, by beagle3
@ngn and with respect to rollback - the easiest way to do that, I think, would be to fork() on executing repl code, if need to bail out, kill the repl-code process, if finished, kill the waiting process. stuff that interacts with the real world, like network or files, would not actually be rolled back of course (and would be weird), but the copy-on-write behaviour would mean you only pay for changed memory unlike the wasm solution.
 
9:08 PM
@ngn how would you define a function that is the constant 1?
would have thought :1 would be that
 
ngn
@nathanrogers {1}?
 
right, I just thought there'd be a shorthand for it
 
ngn
monadic : is return (a special form)
you could project the dyadic form of : to achieve that, but it ends up longer
 right:(:)
 one:right[;1]
 one 2
1
(by "project it" i mean "curry it" or "partially apply it")
 
@ngn your new notation, UPCASE is a list?
like it
 
ngn
@nathanrogers yes but there's a bit of a problem because i need something to indicate "int atom or int list"
and in those cases i use uppercase too
now there's enough content to start thinking about splitting \ help into \+ \: etc kona-style
 
9:22 PM
:) I really like what you've done with it. I'd definitely include the compact version as well because its a concise reference
@ for amend is not "modify in place" is it?
 
ngn
@nathanrogers no, all k objects are values, including namespaces
 
I no longer see the functional / \ descriptions
I guess its d?
ah for dyadic
 
ngn
in apl: a←⎕ns⍬ ⋄ a.k←'v' ⋄ b←a ⋄ b.k←'w'  ⋄ a.k ⍝prints w
in k:   a:`k!"v";          b:a;  b[`k]:"w"; a`k /prints v
 
I see
@ngn I don't see the fold solution with hex numbers you shared yesterday on the list
f/1
is that just ⍣≡
 
ngn
@nathanrogers btw, a.b.c[i;j]+:d is syntax sugar for .[`a`b`c;(i;j);+;d]
 
9:30 PM
or ?
 
ngn
@nathanrogers yes, many overloads are still missing
@nathanrogers yes, usually called "converge"
sometimes "fixpoint"
 
what is the convergence here? It just seems to return either x +0 or x + 1
 
ngn
@nathanrogers and i suspect i don't have to explain what monad\1 does? :)
 
intermediate values I"m guessing
 
ngn
@nathanrogers the interpreter keeps calling the function until its result matches either the previous result or the initial value
@nathanrogers exactly! dyalog doesn't have that (yet)
 
9:34 PM
{⍵,something ⊃⌽⍵}⍣≡ ?
so what your solution does is its
x + 1 until the condition is met, then x + 0, ensuring this result is same as the previous, correct?
 
ngn
@nathanrogers something like that but it should not append when the new result is identical with the old or with the first
maybe ∪ instead of , in some cases
@nathanrogers correct
i think it's slightly faster than an explicit while loop (f g/)
 
is there an x f g / y
?
what I need is accum f g/ input
 
ngn
@nathanrogers there can't be, as f already is the left arg to g/
 
ah, so how would I handle the case where I have an accumulator, and input to update the accumulater iteratively?
and it has to be iteratively because generatively would be too large
 
ngn
@nathanrogers i'm not sure i understand. something like seeded fold? seed dyad/ list?
 
9:39 PM
{{...}[accum;x]}@'input / i guess?
nah, but the accum would refer to its definition in the outer scope
@ngn the way I solved this in apl was through recursion, passing the accumulated value as ⍺ in ⍺∇1↓⍵
in apl it would be like initial {×≢⍵: (⍺ f ⊃⍵) ∇ 1↓⍵ ⋄ ⍺} input
is there an adverb for that?
or just do it recursively using cond and _f?
or maybe there's an array oriented way that I just don't know about?
 
ngn
@nathanrogers i'll have to think
@nathanrogers does kona use _f for recursion? in k5 it was o
 
yes
of course ∇ is best, but :P
 
ngn
@nathanrogers that looks like initial f/ input
 
oh right, because you're providing the first value of the accumulated value
is it possible to do something like a initial f/.input?
 
ngn
or the notorious "reduction of doom" pattern :) ⊃f⍨/⌽(⊂initial),input
@nathanrogers what does the . mean?
 
9:51 PM
input is a list of 3 arguments I'd like to unpack
I suppose that won't be possible
because f will receive initial as x and input as y
blargy blarg honk
input {a:y ; {x,y,z,a}.x}/initial
 
no because init needs to accumulate ((1 2 3);(4 5 6); ....)
that would only accumulate 1 row
 
ngn
any specific examples of input/output?
 
00:00 - 22:0022:00 - 00:00

« first day (734 days earlier)      last day (801 days later) »