« first day (733 days earlier)      last day (802 days later) » 
00:00 - 18:0018:00 - 00:00

12:24 AM
{(#x)#1 0}!12
why does this not work how I expect?
(#1 2 3 4 5 6 7 8 9 10)#1 0
this does what I expect
(#!10)#1 0
1 0 1 0 1 0 1 0 1 0
and this
can someone explain the output to group? 1 0!(0 2 4 6 8;1 3 5 7 9)
 
@nathanrogers seems functions are always interpreted as nouns. Just like 1!12 calls the 2-arg !, {…}!12 does too
@nathanrogers it's like APLs {⊂⍺⍵}⌸ except it's a dictionary, not a vector of pairs of entries
 
12:40 AM
@dzaima I get that its an index grouping, but how do I get the values out?
@dzaima does this mean I have to parenthesize the argument?
that's annoying
 
@nathanrogers or {(#x)#1 0}@!12
in The APL Orchard, Mar 4 at 20:43, by ngn
@rak1507 keys !d, values . d
 
oh interesting
but what about value by key?
 
@nathanrogers regular indexing. (=10#0 1)0 and (=10#0 1)1 :)
(both (=10#0 1)@0 and (=10#0 1)[0] work too of course)
 
and is there some way to commute?
 
@nathanrogers as in APL ? no
 
12:44 AM
what about composition?
(+,-) style
 
@nathanrogers there are no trains of course
composition - you have the short form of {… x} - e.g. (-%) 10 for a function to negate sqrt. There's also projection - -[;1] 10
 
what about ⎕←?
 
@nathanrogers 1@"hello world" and ` 0:"hello world" appear to output with a newline, and ` 1:"hello world" without
and there's `k for formatting an arbitrary object to a string representation
 
1:21 AM
git.sr.ht/~ngn/k/tree/6d1476b1012b193eb478219df374d1e9c0a055c6/… for some reason this looks corrupted or something
oh nvm it just uses those characters in the code, sure
 
2:23 AM
 0: "/mnt/c/d/aoc/2015/3.txt"
'io
0: "/mnt/c/d/aoc/2015/3.txt"
@ngn k crashes when path or file doesn't exist
 
2:35 AM
s31:+\
s32:{,/+\+{x[.=2!!#x]}x}
s3a:{#?y(,/a,\:/:a:1,-1)["^<>v"?x]}
solution for part 1 and 2 of adventofcode.com/2015/day/3
critiques? Yes I know this can be solved with imaginaries, I'm looking for advice on idiomatic K
Really this is just a translation of my APL solution
@ngn some feedback on the help menu.
1. I love the examples. Super helpful, and immediate
2. I still think the original table is useful.
2a. I would make \ display the menu of all options for \, like \w \h \l etc, and keep an option to display the compact table you had originally to get an overview of everything on a tight single screen
 
3:09 AM
@JohnE is there a way to do an inline print?
 
could you clarify what you mean? ``` `0:"foo" ``` in most of the oK frontends will print to stdout and yield "foo" as a result
 
I can do something like 1 + ⎕←1 2 3
it will print 1 2 3 and still evaluate
also can you tell me how to coerce data types?
 
``` `c$65 66 67``` casts numbers to characters, and simply doing arithmetic with characters should coerce them to numbers. Monadic $ converts datatypes into charvecs of their display representation
 
I've read in multiple lines of text, how do I pass each line to a function, I'm getting rank error
10# 0: "2015/2.txt"
("20x3x11"
"15x27x5"
"6x29x7"
"30x15x9"
"19x29x21"
"10x4x15"
"1x26x4"
"1x5x18"
"10x15x23"
"10x14x20")
'rnk
{"x"\x}/:10# 0: "2015/2.txt"
^
 
you probably just want "each" (')
 
3:23 AM
what's the difference
 
eachright takes a left and right argument and applies them through a dyadic verb. each takes a right argument and applies each element of it through a monadic verb
 
{"x"\x}'5# 0: "2015/2.txt"
(("20";,"3";"11")
("15";"27";,"5")
(,"6";"29";,"7")
("30";"15";,"9")
("19";"29";"21"))
some of the values are lists, and I'm getting length errors on the function I'm applying it to
 
all of those values are lists. some of them happen to be one character long, and others are two characters long
 
{*/"x"\x}'5# 0: "2015/2.txt"
'len
{*/"x"\x}
 
,"A" is an enclosed character aka a charvec of length 1
whereas "A" would simply be a scalar character
 
3:27 AM
I don't understand how to avoid the length error
 
I suspect that what you want is something like this:

"x"\"20x3x11"
("20"
,"3"
"11")
.:'"x"\"20x3x11"
20 3 11
*/.:'"x"\"20x3x11"
660
(*/.:'"x"\)'("20x3x11";"9x10x11")
660 990
{*/.:'"x"\x}'("20x3x11";"9x10x11")
660 990
 
getting a rank error with .:
.' works though
 
ah yes; my interpreter is more permissive about colon suffixes which are not strictly necessary
the point is you need to turn the charvec into a number before you can take a product over it
 
s02p:{{.'"x"\x}'x}
s02p 0: "2015/2.txt"
'typ
s02p 0: "2015/2.txt"
why do I need s02p@0:...
I don't understand when or why I need @
 
3:56 AM
@ngn how do I define a multiline function like I would in a dfn or some such?
 
f:{g:{
 x};g@x}
 
semicolons and newlines are interchangeable
you'll notice that the prettyprinter in the REPL takes advantage of this when displaying nested structures
 
I'm getting a domain error when loading a .k file
with just some function definitions
https://tio.run/##dVFRctowEP3nFBszE8AChGQgiSYtvQfQGY0RxBMjE0vOiPH4HD1QD0Z3DY3pR/W12n37dt@@94k92MvFGVUzHgbnptfj4Iq88llhwQE9Djt9BmsxcNnBZvvMlA40nBB6MNaUOodUO4MpDiddYuRN8LDPcoOgnpsJreoAYhINYRStzs2N9qhPkNldlhoHvgABRQkTQXihqGnN@Ba@Hk6vjlSUbRFqwYZsE0ariWiwuEcm7EZCOJXFoTTOZZ8GtRwN7pnNhIJ4piCSM7HgYuqDj0gqMWERCZ7m//7F08uiR9tL3MZAPXzkesRkzLhWMWdyoMI4Ds1NCo4t9jR5B0z@/kW7UkJC@lbZ97bgiEteuWIeRoxxGYe17L@GbXMn80rSMSCbfzMYuKPOc@M88ZxUXU8HUYg2oRmErv2OJy1MmRo8iG8PIBVQ34@vI8juCFIQgEQvZ8v5c3JNylsyeZ7LZLGkWyToZH8VhmOuxxvFlVZiPBGjdfTz9fsnWrslKyqbfVQG51fWkwRb7NBh6iZfE/R1s4X/vNZlcKm2hJctvh5ztmF1WE@/yYeHPl6rE9zhQef
that's my whole file
\l file.k
all of the definitions work individually
\l "2015.k" io error
\l 2015.k domain error
maybe its line endings?
i just went through my whole file in vim, and replaced the line endings and same issue
 
ngn
4:20 AM
@nathanrogers oops. it just closes stdin but that's bad enough
 
ndr@MSI:~/k$ ./k
\l "repl.k"
'io
 
ngn
@nathanrogers no complex numbers in k
@nathanrogers i think that's good code. you're a quick learner. so s3a's y should be one of s31 and s32?
 
@ngn I did monkey around with k first before APL
 
ngn
@nathanrogers some minor simplifications: {x[.=2!!#x]}x -> x[.=2!!#x] -> x@.=2!!#x
or: {,/+\+{x[.=2!!#x]}x} -> ,/+\+{x@.=2!!#x}@ (without curlies)
(,/a,\:/:a:1,-1)["^<>v"?x] -> (,/a,\:/:a:1,-1)@"^<>v"?x -> (,/a,\:/:a:1,-1)"^<>v"?x (putting two nouns side by side is like an implicit @)
if code size matters at all, ,/a,\:/:a:1,-1 can be shorter with odometer: +1-2*|!2 2
@nathanrogers menu - sure, just give me time
 
what is @ there are so many contexts
for example when do I need f@x
 
ngn
4:37 AM
@nathanrogers for ⎕← i borrowed " \" (that is: space backslash; nothing to do with "scan") from k9. in docs it's described as "trace" - not a good name..
@nathanrogers fixed
@nathanrogers try again pls (after git pull and make)
 
\l "2015.k"
'io
 
ngn
@nathanrogers without the quotes
 
\l 2015.k
'dom
 
ngn
huh
 
filename?
ndr@MSI:~/k$ ./k
\l repl.k
ngn/k, (c) 2019-2021 ngn, GNU AGPLv3 - https://git.sr.ht/~ngn/k/blob/master/LICENSE
this works
ndr@MSI:/mnt/c/d/aoc$ k
ngn/k, (c) 2019-2021 ngn, GNU AGPLv3 - https://git.sr.ht/~ngn/k/blob/master/LICENSE
\l aoc2015.k
'dom
this doesn't work
\ls
("2015"
"aoc2015.k")
 
ngn
4:49 AM
@nathanrogers is your current directory the same as the one 2015.k is in?
 
I did an mv 2015.k aoc2015.k
yes
ndr@MSI:/mnt/c/d/aoc$ ls
2015 aoc2015.k
 
ngn
in shouldn't matter that the filename starts with a digit
 
ngn
@nathanrogers just 2015? not 2015.k?
 
2015 is directory
2015.k was the file name
I did a move to aoc2015.k to see if it was the leading digit maybe
just a stupid guess
\ls -al
("total 4"
"drwxrwxrwx 1 ndr ndr 512 Mar 9 21:49 ."
"drwxrwxrwx 1 ndr ndr 512 Mar 9 19:24 .."
"drwxrwxrwx 1 ndr ndr 512 Mar 9 21:12 .git"
"drwxrwxrwx 1 ndr ndr 512 Mar 9 20:14 2015"
"-rwxrwxrwx 1 ndr ndr 865 Mar 9 21:45 2015.k")
here it is currently
\l 2015.k
'dom
\l 2015.k
^
and same problem
loading repl.k from just plain execution of k worked fine
its probably my file
40 mins ago, by nathan rogers
https://github.com/ndrogers/adventofcode
 
ngn
4:52 AM
@nathanrogers i am quite puzzled. do you have strace?
 
I haven't made any changes if you want the actual file
what is strace
 
ngn
@nathanrogers a tool that tells you about how a given process interacts with the os
 
just apt install strace?
 
ngn
it prints all syscall invocations
@nathanrogers yes
 
and then strace rlwrap ~/k/k ~/k/repl.k?
or | strace ?
 
ngn
4:54 AM
@nathanrogers rlwrap itself makes a lot of syscalls, so better just strace ./k
it should say something about write()-ing the banner and then it should be trying to read() your input
$ strace ./k
execve("./k", ["./k"], 0x7ffd3a2a89c0 /* 45 vars */) = 0
mmap(NULL, 16777216, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f95a11bc000
read(0,
 
ngn
@nathanrogers another reason it could have failed for: do you have an eol at the eof?
i.e. \n at the end of file
 
not presently
 
ngn
@nathanrogers you should
tail 2015.k -c 1 | hexdump -C should print 0a
 
 \l 2015.k
'prs
se:{+/x'y}
          ^
'
\l 2015.k
^
new error
 
ngn
5:00 AM
at least it's different now :)
windowsy line endings?
 
maybe, but I went in with vim on linux and deleted the newline and inserted a new one:w
 
ngn
@nathanrogers so it seems - you have 0x0a 0x0d in that file
 
what is that
 
ngn
@nathanrogers :set ff=unix should make sure vim is using the correct line endings
@nathanrogers the ascii codes of "\n\r"
 
is there a way to search?
 
ngn
5:04 AM
@nathanrogers search what where?
 
hey, it loaded
oh no
tabs are invalid too?
 
ngn
:)
@nathanrogers yes
who needs more than 1 space for indent anyway :)
 
so about multiline functions, where are the rules for that?
and also how do I introspect my workspace for declared symbols?
 
ngn
@nathanrogers multiline functions are fine, as long as all lines after the first start with a space
@nathanrogers \v in proper k, but i don't have that yet
actually \v and \f for "variables" and "functions". k inherits this artificial distinction from apl.
 
how do I use \ commands in a function?
 
ngn
5:10 AM
@nathanrogers you dot them: ."\\ls"
 
groovy
\l doesn't import definitions?
 
ngn
@nathanrogers it should. it evaluates the content of the file as if its lines were typed in the repl.
(except for those that start with a space - those are continuation lines)
 
I see, it does indeed
any k/q syntax for vim/emacs?
 
load through vundle, or?
 
ngn
5:15 AM
@nathanrogers whatever your favourite plugin manager is. i just append a path to &rtp and don't bother with plugin managers.
 
&rtp?
 
ngn
@nathanrogers vim's :set runtimepath+=..
rtp is its short name
the first line of my .vimrc begins like this: se nocp rtp+=~/k/vim-k/,~/k/vim-c/,..
 
syntax highlighting works but I get this error
 
ngn
@nathanrogers looks like it's coming from fugitive (a vim plugin for git), not me
 
you're correct
I'm not super familiar with vim extension
 
ngn
5:25 AM
it's not hard, just clunky
 
your plugin does interfere with my tmux though :C
 
ngn
@nathanrogers how?
 
I have ctrl + HJKL for tmux pane synergized with vim panes
so I can freely switch between panes of tmux and vim without any interference
and when I try to ctrl+direction I get some error or another
 
ngn
@nathanrogers i don't think i define any key mappings
 
se nocp rtp+=~/k/vim-k/
that at the top of my vimrc
 
ngn
5:29 AM
@nathanrogers do you know if you had cp or nocp before?
 
could have something to do with the mess that is my vimrc
 
ngn
maybe try to se cp on the second line?
 
that breaks everything
 
ngn
sorry, no idea what could be interfering with tmux
 
5:44 AM
you don't bind any hotkeys with your vim plugin?
define any global variables?
 
ngn
@nathanrogers no, it's just a syntax file, filetype detection for *.k, and a few buffer-local settings (indentation, shift width, ..)
 
ngn
@nathanrogers KIndent() (a function) is the only global i define
 
well I haven't the foggiest. I'd rather just live without the syntax highlighting
which is too bad
its nice
It's conflicting with a bunch of plugins, the primary among them is the one doing the tmux pane stuff
there's a Q extension for vs code, but even running vscode from the linux side gives me the same line ending problems
 
6:33 AM
@ngn what is the difference between reading some files that need * and other files which don't?
 
6:44 AM
why am I getting a type error when I try to define a function
f:{$x y}
and then
1 f 2
https://chat.stackexchange.com/transcript/message/57293335#57293335

Wait so every ouput from 0: is a list, and if its one line `*0: file` is sufficient because I'm just getting the first element of the lines as a list of lines. I see
 
7:05 AM
what are legal names in K?
only alphanum with leading alpha?
 
7:28 AM
@ngn yes dude, arrays of functions ftw github.com/ndrogers/adventofcode/blob/main/k/2015.k
 
8:20 AM
@ngn to increase adoption for ngn/k i suggest: 1. split into main and libk, 2. allow custom implementations for os interface, your syscalls as one example. 3. allow external functions to use k types and assign to k variables (as funcs) no need for built ins, maybe a new native function type. 4. things like http server should be a stand alone implementation using libk (no stdin/out with text). 5. ffi is not necessary anymore.
 
@ktye what does 5 mean?
 
@nathanrogers if it's simple enough to write a wrapper and compile it into the interpreter, there's no need for ffi. it's only necessary, if you have no source or cannot compile.
 
so you're saying I would need to wrap whatever library I wanted to use into the interpreter itself
at what point what I begin writing k then?
or you're saying that if I compile with whatever headers and libraries they could be exposed to k in that fashion?
you'll have to forgive me, I'm pretty new to how this all works
 
@nathanrogers you'd have to do that anyway. external libraries do not know k memory/vector model. you pass a k type and want a k result. so you need a wrapper.
 
how would something like a function pointer work? as in a library compiled in needs a function pointer
 
8:29 AM
@nathanrogers you can't call user-defined functions in k with infix syntax. you must do f[1;2]
 
@dzaima that's unfortunate
@dzaima what about multiple variable assignment, or unpacking?
 
in fact, k doesn't even know the type of variables. So f:{x+y};1 f 2 and f:4;1 f 2 must be parsed & executed exactly the same way (and there's no stranding)
@nathanrogers (a;(b;c)):(1;(2;3)) appears to work
 
@dzaima if there's no stranding then how does one catenate a series of items to a list?
 
@nathanrogers ,?
 
between each item?
 
8:32 AM
@nathanrogers oh, you mean a hard-coded vector? (a;b;c;d)
 
wasn't there some way to define infix with ` or something?
or that's haskell
so 0 user defined infix?
 
@dzaima (a stranding-like shortcut for numerical arrays exists, i.e. 1 2 3 is a 3-item vector. But that's only for numbers, and even 1 (2) 3 is an error)
 
good to know
 
@nathanrogers some other ks might have ways to define custom infix functions in a special file somewhere somehow, but that's not ngn/k
 
well that ruins my idea then
 
8:35 AM
some k versions have builtin verbs that are parsed as infix. in some versions you could defined them by assigning them into a special namespace (k-tree directory). ngn does not like it.
 
marking a name as "infixable" would be super great
 
@nathanrogers you would never be able to mark that in the same file using it though, as that requires changing how the name is parsed
 
:C
not even with some kind of lispy #'f syntax?
 
@nathanrogers that'd be for what?
 
`.:'?#f
^ infix notation
I just mean to ask if some kind of notation for infix would make that possible
 
8:43 AM
@nathanrogers you'd either need the separate file method, or have some special "call as infix" syntax, which defeats the purpose
 
 
2 hours later…
ngn
10:19 AM
@dzaima @nathanrogers ngn/k extends k with single-unicode-char identifiers acting as verbs. @coltim wrote this for golfing purposes, it's automatically \l-ed in the wasm interpreter.
 
ngn
10:37 AM
@nathanrogers s02p:{{.'"x"\x}'x} could be s02p:.''"x"\'
{*x} can be written as *: - the colon forces the verb to be monadic
{(x 2)~(x 0)@'day'(x 1)} slightly shorter as {x[2]~x[0]@'day'x 1}
s022 - A++/B can be A+/B. the left arg of the reduction is its initial value.
@nathanrogers these look very suspicious
you defined the same shortcuts in vim and in tmux?
 
 
1 hour later…
11:54 AM
@ngn @coltim cool!
 
 
2 hours later…
2:07 PM
I came up with a couple others - https://ngn.bitbucket.io/k/#eJxdUsty0zAU3fsrFBNaO4mx01IodsiD9/v9TvNQEzVR68iuLSdyCZ6yYQpMt2UGhuExFLas6I4F/ZN8QT+BK6dDZ9hImnPOPffqSDVbrZ07f+HipctXrl67fuPmrdt37t67/+Dho8dPnj5TFWyreLnTJSu9/ipdcwfM89eDkEfDkYg3VIXZqlWcmz+5cOr04hlV0SYv39q6rS4x1UTmqkcZGlHeR4yMXMpIqGh/fkgeqUvI5N4aYXSDKNrBp51fALeRZSPTDyjjiqLt7+n2c3HcOmHl4xfIXHE9zI0uHUoGxMX9PWRSNiRBCA6TzR1byseGAC1eDj034gQNsRul7Hcgs/Vi6VjseHXh5OJGodiKHU2UY31sm5qYifV8ppgHH2HEDfAIMOtNS+20tu0m1ZZwtKrQsxk4ZNo89qUQNtI1OHVhsHdSC6aWboiSBWRIeywawG0mr7/pdlJGpkvC0OB9zAyyHmE3ZdLRq6V09LAjoV0Ql5DZCwjmJPhPvzvVl6W+S6YFn6HgLDKZx9E/3ZYc
but it's too open ended for me to really flesh it out
 
2:24 PM
@ngn `prc:({*x};s02p;{*x}) `
\l 2015.k / 👍
prc:(*;s02p;*)
 \l 2015.k
rlwrap: warning: k crashed, killed by SIGSEGV (core dumped).
rlwrap itself has not crashed, but for transparency,
it will now kill itself with the same signal
\l 2015.k
'rnk
{.'"x"\'x}
^
I get other errors when I define s02p:.'"x"\'
its these kinds of unpredictable errors that make me afraid of being clever, I had tried the just using *, and I got weird behavior, so I wrapped in {} and the weirdness abated, so I just default to it
 
{*x} is monadic *; primitives default to being dyadic. maybe try (*:;s02p;*:)?
 
2:39 PM
@ngn I commented out the suspicious lines in vim last night, didn't change anything about the behavior. The true culprit is Plugin 'christoomey/vim-tmux-navigator'
if I disable this line, there's no issues, if I don't, ctrl + hjlk gives me a giant screen full error about how something isn't valid input, and args is not defined
I looked for args in that library and didn't see it off hand
if I comment out that plugin I can
1. switch between panes in vim using the hotkeys
2. switch between panes in tmux using the hotkeys

I cannot
3. switch between the panes of vim and tmux if vim is open in 1 tmux pane
so what that plugin allows me to do is seemlessly switch between panes of either seamlessly
but I don't know enough about tmux or vim to implement such behavior
I see the problem here, I forgot an '
' adjacent to " had me blurry-eyed
@coltim good suggestion... how do I know when that sort of thing is necessary?
(×):*
2×3
6
@ngn that's excellent
just like, when do I know when I have f:{...} and something like 0: "file.txt"1 but I can't just f 0:... I need f@0:... how do I know when to use @?
 
 
2 hours later…
4:46 PM
@ngn ok, clearly I don't understand the limitations of the unicode definitions. I defined a few using unicode, and I'm getting bizarro world output
'val
����������������������������������������������������������������
^
like I defined (⊃):*: because that's what worked in @coltim suggestion from earlier defining * as *:, it worked in that case, but in s021:{...,*x} I tried to use ⊃x but get a value error
 
@nathanrogers to define a monadic function you need to do (⊃:):*: (you can separately define the dyadic version with (⊃):)
 
but it is monadic
x,*x is monadic
oh, I see
 
the function definition/code is monadic but I think you need to explicitly indicate that the function is to be called monadically
 
that's a lot of :
 
(I believe the benefit here is that you can define both a monadic and a dyadic version of the same underlying character)
 
4:53 PM
(⍸:):&:
(⌊):&
so like this would be monadic and dyadic?
 
yes; I was referring to e.g. (×):*;(×:):{(x>0)-x<0} though
 
idk what that is
I can't read that
 
(×):* defines dyadic × as times/mul; (×:):{(x>0)-x<0} defines monadic × as signum
 
5:13 PM
is there an idiom for sign? oh you literally just answered that
(⊃:):*:                  / first
(⍳:):!:                  / iota
(⍸:):&:                  / where
(⌊):&                    / min
(∪:):?:                  / unique
(≢:):#:                  / count
(↑):#                    / take
(↓):{((- ×x)*(≢y)-⍴x)↑y} / drop
(⌽:):|:                  / reverse
(×:):{(x>0)-x<0}         / signum
(⍴:):{x|-x}              / abs
these all work
guess I should define signum further up
idk what to do for abs though
 
is your definition of drop there different than _?
like 2_1 2 3 or -2_"abcdef"
 
2↓⍳3
,2
-2↓"abcdef"
"abcd"
I didn't know about _ :P
 
5:29 PM
how would I define one of these for something like a reduce or some such
(Σ:):{x f/ y}
is there a way to do something like that? @coltim
 
@nathanrogers no, no custom adverbs
 
DARN
drat
fiddlesticks
 
well, at least with the adverb syntax stuff. functions can take functions and apply them however they want
 
^ (Σ):{[f;x;y] f/(,x),y}; Σ[+;100;1 2 3]
 
there's no way to say, partially bind sigma to return a function?
(Σ+) returns a function awaiting x y?
(Σ):{[f] {f/(,x),y}[f;]}
I would have thought something like this would allow me to do 3 (Σ+) !10
but that becomes a user defined function doesn't it
aw horney toads
 
5:45 PM
@nathanrogers you definitely can't do that. Σ doesn't know if it should be a verb or an adverb
 
you can do Σ[+;][100;1 2 3] and Σ[+;;][100;1 2 3] (no clue which is better; (Σ[+])[100;1 2 3] doesn't work)
 
even then, what I'd really want is 1 (Σ[+]) !10
oh well, not important anyway
what I really want to know is how do you handle "namespacing" and "importing"
 
@nathanrogers that'd be completely new syntax, which is quite a bit of work for a feature for golfing or whatever
@dzaima (oh, s:Σ; s[+][100;1 2 3] works)
 
@ngn say i have that little testing data structure and function to run tests, but say I'm going to do 2016, 2017, etc ,and I want to move all my tests into a testing file that imports each year, but each year is the same format.

day 1 part 1
solution 1 part 1
s011

so I'll have the same names accross multiple files. How can I "import" and "namespace" these so that they're referenced correctly
and are there any parallels of "exports" from a given file? in order to encapsulate definitions?
 
5:51 PM
@dzaima it's a total hack but you can do ((+) Σ 100)1 2 3 lol
 
ngn
@nathanrogers put them in a common file and "import" them with \l?
 
@coltim ooh fun
 
@ngn but then every definition will be
s2015011
s2015022
...
s2016031
...
that's obnoxious
 
ngn
@nathanrogers for "namespacing" you could use something like util.func0:{..}; util.func1:{..}; .. instead of func0:{..}; func1:{..}; ..
 
what is util?
just a name I've chosen, or...?
 
ngn
5:54 PM
but i find 99% of the time namespacing isn't really necessary
@nathanrogers yeah, whatever you choose
 
well I gave you an example where it is
name format is s (solution) day (nn) part(n) ? (signifier)
s 01 1
s011 for each year there will be an s011
and an s012
can the "namespace" be a number?
or does it have to start with alpha
 
ngn
@nathanrogers yes but then you can't access it with .
 
ngn
ns.name is equivalent to ns[`name]
you can use ns[12] but not ns.12
 
no I mean ns, can ns be a number
 
ngn
5:58 PM
@nathanrogers ah.. no. it must be a dict.
 
ok, that's fine
 
ngn
@nathanrogers btw, for my aoc-s i decided to split the code in multiple files, one per problem
so they can be run in isolation
 
``fy!(::;{x};{x}), am I to interpret this as NIL f y dict of (NIL; function f; function y)
?
 
00:00 - 18:0018:00 - 00:00

« first day (733 days earlier)      last day (802 days later) »