!laJBzNwLcAOMAbAEeQ:matrix.org

k

673 Members
Discussion about the various k languages. For ngn/k dicussion, please see #ngnk:matrix.org16 Servers

Load older messages


SenderMessageTime
21 Apr 2024
@scrawl:matrix.orgscrawl
In reply to @_discord_870115701279584326:t2bot.io
Thanks. I’ve built a bunch of these but wasn’t sure what the “M tokenizer” was.
are they publicly available?
10:41:56
@scrawl:matrix.orgscrawl
In reply to @_discord_1140710589165994105:t2bot.io
discodoug here's an animation of the tokenizer: ktye.github.io/kweb/tok.html
nice
10:42:58
@_discord_870115701279584326:t2bot.iodiscodoug Mostly somewhere on my [github[(https://github.com/gitonthescene/ngnk-lsp/blob/main/k/semantic.k). 10:43:38
@_discord_870115701279584326:t2bot.iodiscodoug * Mostly somewhere on my [github](https://github.com/gitonthescene/ngnk-lsp/blob/main/k/semantic.k). 10:43:50
@_discord_870115701279584326:t2bot.iodiscodoug I copied the basic form from stuff on nsl.com 10:44:42
22 Apr 2024
@_discord_461809493534179338:t2bot.iojenny joined the room.03:22:44
@_discord_595317473247756288:t2bot.ioalexshroyer Based on dzaima (discord) 's suggestions, my parser is a little different from ngn/k but I think it's usable.
Here are some of the trickier test cases that now pass:
 a+        ⇒ (prj + a)
 +-        ⇒ (cmp + (prj -))
 (+)-      ⇒ (prj - +)
 +(-)      ⇒ (+ -)
 a+-       ⇒ (cmp (prj + a) (prj -))
 *a+-      ⇒ (cmp * (cmp (prj + a) (prj -)))
 +-*       ⇒ (cmp + (cmp - (prj *)))
16:52:06
@_discord_595317473247756288:t2bot.ioalexshroyer One more:
(a+)-      ⇒ (prj - (prj + a))
16:53:51
@_discord_595317473247756288:t2bot.ioalexshroyer Ugh, now I have f[x]y parsing like f([x]y) but I think it should be (f[x])y. 17:32:02
@dzaima:matrix.orgdzaima […] is somewhat like an adverb, except the result is a noun instead of a verb 17:38:37
@dzaima:matrix.orgdzaima * x[…] is somewhat like an adverb, except the result is a noun instead of a verb 17:38:48
@_discord_595317473247756288:t2bot.ioalexshroyer Makes sense. 17:57:58
23 Apr 2024
@chrispsn:matrix.orgchrispsnWhat’s a good syntax for defining function inverses?13:14:49
@chrispsn:matrix.orgchrispsn Specifically thinking of format de-serialisation 13:16:58
@_discord_595317473247756288:t2bot.ioalexshroyer I like the idea of filling holes in the current syntax as much as possible
f:{regular}:{inverse}

f:{regular}
{f}:{inverse}

As for calling the inverse of f, that seems trickier. Maybe just a special "call the inverse of f" function like inv[f][args].
Or maybe add a unary adverb overload like ':f x.
14:44:33
@chrispsn:matrix.orgchrispsn
In reply to @_discord_595317473247756288:t2bot.io
I like the idea of filling holes in the current syntax as much as possible
f:{regular}:{inverse}

f:{regular}
{f}:{inverse}

As for calling the inverse of f, that seems trickier. Maybe just a special "call the inverse of f" function like inv[f][args].
Or maybe add a unary adverb overload like ':f x.
assigning to a primitive/composition/lambda is an interesting idea
15:10:01
@chrispsn:matrix.orgchrispsni don't think there'd be a conflict with ngn/k's "use unicode chars as verbs" feature15:11:18
@chrispsn:matrix.orgchrispsnhmm, on second thoughts, maybe it would. unless it's a composition15:11:59
@chrispsn:matrix.orgchrispsn
In reply to @_discord_595317473247756288:t2bot.io
I like the idea of filling holes in the current syntax as much as possible
f:{regular}:{inverse}

f:{regular}
{f}:{inverse}

As for calling the inverse of f, that seems trickier. Maybe just a special "call the inverse of f" function like inv[f][args].
Or maybe add a unary adverb overload like ':f x.
calling inverse would be done as: (f)?
15:12:44
@chrispsn:matrix.orgchrispsn like it is for `j? etc 15:13:57
@_discord_595317473247756288:t2bot.ioalexshroyer Taking more inspiration from J's "assign obverse/adverse":
f:{a}:{b} /f is a, f inverse is b
f:{a}::{b} /try a, if it errors, call b
15:38:19
@_discord_595317473247756288:t2bot.ioalexshroyer I should note that currently this is already used in ngn/k: f:{a}:{b} just assigns f to {b}. 15:40:19
@dzaima:matrix.orgdzaima fun: f (:) 3 returns 3 and doesn't error, even if f doesn't exist, and it does not assign to f either 15:45:43
@_discord_595317473247756288:t2bot.ioalexshroyer f(:regular;inverse;except) 15:54:11
@anaseto:matrix.organaseto
In reply to @dzaima:matrix.org
fun: f (:) 3 returns 3 and doesn't error, even if f doesn't exist, and it does not assign to f either
Yeah, ngn/k's parsing of : is a bit surprising, parens usually nominalize, so one would expect (:) to always be "right", but for some reason parens around : disappear during parsing if there's something on the right.
16:45:11
@anaseto:matrix.organaseto It's parsed as f (: 3). 16:46:32
@dzaima:matrix.orgdzaima ah, and that's a "return" 17:23:04
@_discord_870115701279584326:t2bot.iodiscodoug That feels like a bug to me. Not that I have a suggested fix… 21:43:25
@_discord_624974820840308737:t2bot.iocoltim f (::) 3 also feels wrong 22:09:28
@ovf:beeper.comovf to make users of ngn/k feel better, k4 has a related parser quirk: (:;`a)~-5!"()a"
(-5! is parse)
22:17:50

Show newer messages


Back to Room ListRoom Version: 6