« first day (692 days earlier)      last day (1946 days later) » 

9:08 AM
CMC: Return the array '**' (i.e. ** isn't a valid solution) without using the character *.
 
ngn
@Adám anything to do with codegolf.stackexchange.com/a/115864?
⍕⍨⍳2 ⍝ with ⎕io←1
using the same trick, this one was close
 
9:36 AM
That can be also matched by 10 9⍕⍪⍳10
 
ngn
@H.PWiz yeah, that looks better
 
@ngn No. Comes from some internal development work.
@ngn Oh well, that was quick.
 
ngn
@GalenIvanov there's a simpler way to get the "diagonal" here
you could do prm'x without transposing it and then take the i-th elements from the i-th row of permutations
@GalenIvanov just use a double each on the indexing verb: |/+/(prm'x)@''!#x
 
9:53 AM
Also xnor pointed out that the solution is nearly >./ .+ in J, if anyone wants to fix it for rectangles and post
 
ngn
@GalenIvanov in ,// the first / is "reduce" (as in ,/ which is known as "raze" in the k/q world) but the second / is "converge" (like apl's fixed-point operator ⍣≡)
 
@ngn This is really nice
 
10:07 AM
Thank you for your help!
 
ngn
@GalenIvanov my pleasure :)
"case" looks interesting but it looks like oK doesn't support it
 
@ngn I'll take a look at the kx site
One more question: How to use \ (decode) when we don't know the number of necessary (binary for example) digits?
 
ngn
@GalenIvanov in my implementation i made 2\ return as many digits as necessary. i don't know if there's a way to do that in other ks
 
@ngn ok. I was thinking about using log or something, but it's too long
 
ngn
@GalenIvanov which challenge is that for? sometimes solutions work even with leading 0s
 
10:18 AM
Not related to anything in particular
 
ngn
(64#2)\x should give a sufficient number of bits
 
@ngn yes, it should work. I need to go now, bye!
 
ngn
for decimal there's .:'$x
@GalenIvanov bye!
 
 
1 hour later…
11:44 AM
@H.PWiz One way to do it is [:>./ .+#@{.{.] (take as many rows form the input as the length ot the first row, the needed rows are padded with zeros)
 
ngn
12:27 PM
@GalenIvanov what does it do without the [:? (i'm a j noob)
ah, i firured it out: (f g h i)x ←→ (f (g h i))x ←→ x f ((g h i)x), so that's why it needs to be "capped" with [:
 
12:47 PM
@ngn Which is a horribly hacky thing, imho. Dyalog's 2-trains are much saner.
Sometimes I just long for the super simple APL without namespaces, user-defined operators, function assignments, dfns, control structures, etc.
All these sometimes give absurd situations.
 
ngn
@Adám i agree, passing x as the left argument isn't so common. using an explicit ] for it wouldn't be too expensive
 
@ngn [ ()?
 
ngn
@Adám well, i was talking in the context of monadic trains, like Galen's solution above
 
@ngn Oh, right. It is just that J convention has x for and y for
 
1:07 PM
@ngn Yes, right. It's just capping the 2 verbs into a fork and not a hook
 
dfns.dyalog.com is very useful, but am I supposed to copy definitions out of it wholesale to use them in my code, or are these in the stdlib and I just don't know how to import 'em?
(Or; am I supposed to download the workspace and then import them)
 
@Lynn names ⎕CY 'dfns' or just ⎕CY 'dfns' if you want them all.
 
The workspace comes with a normal install of Dyalog
 
oh, neat :)
 
@Lynn You may want to put them in a namespace. E.g. you could do (⍎'dfns'⎕NS⍬).⎕CY'dfns'
@Lynn At the cost of performance, but gaining neatness, you can define the function WS←{⍺←⎕NS ⍬ ⋄ ⍺⊣⍺.⎕CY ⍵} so you can do (WS'dfns').pco 13. (Note: pre-17.0 you'll have to make that a tradfn or use error trapping.)
 
1:29 PM
@Adám It's really horrible with the trains sometimes, when you need forks and not hooks and it's a long sequence - there can be a lot of [:
I wish there were modifiers saying that what follows is a sequence of single verbs (to eliminate @), a train of forks (to eliminate [:) or a train of hooks (to eliminate () )
Of course these make sense in golfing, I doubt they really matter in "serious" coding
 
@Adám so just tradfns for user functions?
 
@GalenIvanov In Dyalog, for a longer sequence of monadics, I'd just do {f g h i j k ⍵}, but I can't figure out how to do that in J. 3(3:'x+y')4 doesn't seem to work.
@dzaima Yeah.
 
3 (dyad : 'x+y') 4 I believe
(dyad is just 4)
 
but tradfns are horrible (in comparison to my style dfns, at least) :|
 
@dzaima Why? The only real issue I have with them is that the "closing character" is the same as the opening character () so you can't nest them. Oh, and having to declare your locals instead of declaring your globals is tedious.
 
1:40 PM
@Lynn Yes, 3(4 :'x+y')4 also works
@Adám 3 : is for monad
 
@Adám those, and that they force multiline code, can't be inlined, implicitly print non-shy results
also the returning system of them is strange
 
@dzaima Ah, good points. Inlining could be allowed just by allowing after the header. I agree that everything should be shy (except in the session) but it isn't really a feature of tradfns per se.
@dzaima What do you mean? That they can return a function?
 
@Adám oh i guess that too, but the whole idea of having a return variable feels weird to me
 
@dzaima It is pretty neat sometimes when you need to assemble the result. Or for modifying an argument. E.g.
text←Quote text
text,←'"'
text,⍨←'"'
@dzaima How about this one-liner tradfn:
(y y)←Duplicate y
@dzaima (,2)≡⍴:
 (a b)←Pair(a b)
 
@Adám oh god what
 
1:50 PM
@dzaima {⍺ ⍵}:
 (a b)←a Juxtapose b
 
@Adám that feels more like abuse than the intended use
@Adám what that should do isn't anywhere near intuitive to me
 
@dzaima It throws an error if given anything but a length-2 vector.
 
trains are about hiding inputs and expressing transformations. one-liner tradfns are about hiding the transformations and expressing the inputs & outputs :p
 
hmph. I'm trying to solve adventofcode.com/2018/day/17 in Dyalog, and I seem to have something working gist.github.com/lynn/1dd09720a2d2e08a1602595c644c8827
but it's too slow to handle the real input
is anything obviously slow about this, other than the fact that it is a ⌺(3 3)⍣≡ ? is there any hope I can speed this up?
 
@Lynn I don't have time to look at that in detail right now, but if you just need display, you know you can use ]display? Alternatively, just turn ]boxing on -style=max.
 
2:04 PM
(the TiO link was too long, but it works on there. it does this:)
That works from the REPL, but I get line(33,0) : error AC0008: error (VALUE ERROR) executing line "]boxing on" in a script
 
@Lynn Right, you need ⎕SE.UCMD'box on'
 
on TiO at least
 
ngn
@Adám not just tedious, it's dangerous because the default is dynamic scoping - a tradfn can create and modify the local variables of its caller
 
@ngn A dfn can modify the local variables of its definer.
 
ngn
@Adám not caller. that is fine
 
2:21 PM
Dyalog doesn't happen to have something like sparse arrays, does it?
 
@Lynn as cool as stencil is, it's pretty slow as dyalog is pretty slow with non-vecorized functions. i opted for doing that aoc in java
 
mmm, I suppose you're right
 
@Lynn Not yet. Coming (as in you can make them yourself) soon™. You can kind-of hack them now.
 
@Adám magic arrays, if I recall correctly?
 
@dzaima Yes.
 
2:24 PM
I wanted to be like "woo, arrays! cellular automata!" about this but this problem is just too darn big
 
@Lynn todays aoc is much more cellular automata, and i did indeed solve it in apl
 
oh wow you're right
ugh that looks so much easier
I don't want to do this one anymore ._.
 
@Adám "as in you can make them yourself" so i still have to do the hard work, dyalog will just give me the ability to make e.g. + vectorize on my items, right?
actually you could probably do the horizontal maths for D17 vectorizedly, but sadly the input is much more vertical than horizontal
 
@dzaima It isn't really very hard. Just look-up indices in the list of indices, and then use that to look-up in the list of values. I think you'll have to :Implements ⍶+⍹ or something with a trivial definition.
 
ngn
@Lynn +1 in square brackets is a symptom you might want to use ⎕io←0 :)
 
2:31 PM
@Adám that's assuming a lookup indices array fits for the purpose, which it doesn't if i plan on inserting & removing a couple billion of items in groups
still want nice simple hashmaps in apl
 
@dzaima Wait, you do have hashed arrays, if that helps?
 
@Adám hashed arrays are ordered afaik, so removing a random element from it should be O(n)
 
@Adám highlights another thing I hate about J, because 3: is a verb, you have to have a space after the 3 otherwise it errors out
 
@Cowsquack I agree that that's horrible. Shy didn't they just allow array operand to ~‽ I'm currently proposing 3⍨ etc. Same goes for inner product which always needs a space on its left: +/ .*
 
3:30 PM
@Lynn I did try to speed it up just by (blindly) turning all of those conditions into one vectorised expression, and then replacing u l r dl (etc) with whole arrays. This is faster. But either I made a mistake or some of your logic is wrong. I have this case: tio.run/##K85JLM5ILf7/…
Also, I just closed my session without thinking, so I don't have any code to show
 
ah, my code is wrong ^^
 
@H.PWiz by some reason that picture made me want to have a go at doing the aoc in apl :|
 
sl←(dl∊1 6)∧(l=3)
sr←(dr∊1 6)∧(r=3)

should be l, r ∊3 4 5 or something, so that "water that touched a border" also propagates horizontally
for what it's worth, I had
0 = space
1 = # wall
2 = | falling water
3 = ~ horizontal water
4 = ⍨ water blocked off to the left
5 = ⍨ water blocked off to the right
6 = ≈ water blocked off at both sides
 
To make a single expression I just did:
f←{⍵+⍺×⍵=0}
⍵ f....f(n2×cond2)f(n1×cond1)
 
that's a clever way to make it fast!
thanks for poking at it anyway
 
3:50 PM
argh why cant i just get a non-O(n^2) \ ಠ___ಠ
that not existing completely breaks my idea of what i wanted to do, and my apl is way way too slow for a thing that took 5s in raw java
though reduce is a very ¨y operation anyway, forgot about that ಠ_ಠ
 
4:22 PM
what's an APLy way to transform 0 0 2 1 1 1 0 1 1 0 to 0 0 2 2 2 2 0 1 1 0 - aka replace /21+/ with all 2s?
 
Will there be 2 0s in the input?
 
@H.PWiz yeah, though that special-case is easily special-caseable
 
ngn
@dzaima (××2⌈/0,⊢)⍣≡
 
oh, meant /21*/, but doesn't really matter
@ngn that's O(n^2) though
 
ngn
@dzaima oh, is it for fastest-code?
 
4:28 PM
@ngn no, just fast code. For D17 AoC
 
ngn
@dzaima what do the 0s, 1s, and 2s represent? just curious
 
@ngn 0 = air, 1 = floor, 2 = settled flowing water
my idea was that i could at least have vectorizable instructions horizontally, but that needs that to be fast
 
ngn
4:44 PM
@dzaima shouldn't you replace in both directions? /1+21+/
 
@ngn that's easily done by executing the same thing on , but yeah
 
ngn
@dzaima maybe something like this? {a+a×b∊(⍵=2)/b←+\~a←×⍵}
 
@ngn oh wow that's beautiful
how do you even think of doing that :p
well i shouldn't really be asking, it is ngn who wrote it
 
ngn
@dzaima there's no magic, i'm just trying to use mostly vector operations
 
4:59 PM
@ngn yeah it's not magic, it's just a very obscure way of achieving that
 
ngn
@dzaima that bothers me though
 
@ngn yeah, that was my first thought too
 
ngn
5:18 PM
@dzaima i tried using only array operations but it's not faster :( {c←(1+⊃⌽b←+\0,2</a←×⍵)⍴1 ⋄ c[(⍵=2)/b]←2 ⋄ a×c[b]}
(⎕io←0)
 
@ngn wouldn't that be better written with @?
(not that i expect that to have a performance impact)
 
ngn
@dzaima maybe. i don't have @, my version of dyalog is old
 
ah
@ngn it's ~30% faster for me
 
ngn
@dzaima @ compared to no @?
 
@ is usually slower. I don't think it can ever be faster
 
5:25 PM
@ngn your new vs old
 
ngn
@dzaima ah
 
@H.PWiz it can tell that it doesn't need to copy the data of c
 
So, approx the same speed?
 
ngn
@dzaima c[ ]←2 should know that too
 
oh right forgot what the code does :|
hmm is there a way i could make dyalog do ⎕wa after every REPL entry? dyalog not collecting its garbage has frozen my system way too many times
(or alternatively a way to make linux not suck when it's low on memory)
 
5:33 PM
With a smaller MAXWS, would you still have a problem?
 
@H.PWiz then i wouldn't have as much ram available for dyalog when i need it :|
@ and [] seem to be around the same speed
@dzaima really just having the repl give me an option to do some post-processing would be nice. e.g. when i do, i almost never intend to print a 100000000-item array
 
5:53 PM
@Adám should this be happening?
 
@dzaima I've noticed it being broken. I need to investigate.
@dzaima I don't think there is an event for returning to the 6-space prompt, but there is one for printing, so if your expression only prints at the very end, you can attach a ⎕WA handler to that.
 
@Adám i wouldn't mind it ⎕WAing after each line printed really, where could i find that?
 
oh cool now 2 executed in the repl errors
 
@dzaima ⍨
 
6:04 PM
oh cool now everything is 2 :D
 
@dzaima Btw, this is what ]box etc. uses.
 
@Adám oh so doing that is gonna break it?
 
@dzaima Yeah. You could build in a hook in ⎕SE.Dyalog.Out.Filter which is the callback function.
 
how could i put stuff to execute on ws loading again?
 
⎕lx
 
6:10 PM
@dzaima ^ is per-workspace. WorkspaceLoaded Event is "global".
 
@Adám "global" to what/where is it stored?
also how do i do ]box on on startup
 
@dzaima It is a session event, so part of ⎕SE, and ⎕SE survives )load and )clear.
 
@Adám and dyalog closing & opening?
 
@dzaima Save your session with boxing on or make it part of setup.dyalog.
 
what is save session
 
6:14 PM
@dzaima the FileWrite method (which has a menu entry on Windows).
 
@Adám i'm not on windows, so what's a FileWrite
 
@dzaima 2⎕NQ'⎕SE' 'FileWrite'
 
and what do i do with that. sorry for asking literally all the questions :|
so the workspace, REPL history & session are all stored separately? ._.
 
@dzaima '⎕SE'⎕WG'File' is where your current ⎕SE came from. You can ⎕WS this property to choose another filename, then 2⎕NQ'⎕SE' 'FileRead' to load that file or 2⎕NQ'⎕SE' 'FileWrite' to save your current session to the selected filename. On startup, APL loads your default session or whichever session you specify from the commandline or with a environment variable. You can use this to prepopulate ⎕SE.
If you don't change the name, just save to the current file, you'll get your ⎕SE changes back next time you start.
 
6:23 PM
@dzaima Somehow you accessed part of our overnight build process. That shouldn't be possible. How did you get there?
 
..executed 2⎕NQ'⎕SE' 'FileRead'
so what i should do is ]box on, then 2⎕NQ'⎕SE' 'FileRead' and now restarting dyalog should start with boxing on? cause that's not happening
 
@dzaima No, ]box on then FileWrite!
 
@Adám right, miscopied that message. that doesn't work
 
@dzaima Well, now you session file is probably well messed up. You may want to reinstall, or copy that file from the installation image. Next time, make a copy to somewhere else before you begin experimenting.
 
6:41 PM
no the session file is equal to the starting one
 
@dzaima Just starting APL, ]box on then saving the session should do the trick. If that doesn't work, then email support@ or ping me during office hours and we'll sort it out.
 
@Adám saving the session ≡ running 2⎕NQ'⎕SE' 'FileWrite', which should write to '⎕SE'⎕WG'File', right?
 
@dzaima Yes.
 
 
2 hours later…
9:11 PM
oh monadic is doing strange things
 
@dzaima It looks like it is doubly enclosing. Should be ,⊂.
 
and it violates ⎕boxsimple←0 :|
 
Hm, another idea for an additional operator: {⍺←⊢ ⋄ 0 1000::⍺ ⍵⍵ ⍵ ⋄ ⍺ ⍺⍺ ⍵}
 
@Adám personally i hate allowing things to rely on errors
e.g. if there's a thing that relies on erroring on non-0/1 values, it'll break if the domain of it is extended
 
@dzaima Yes, me to, and more so over time. I'd much rather write a lot of code to pre-check. But I was trying to solve this which would be ⍎⌺←'⍞'⊣⎕RTL∘← assuming for the above and is Sink.
@dzaima True. E.g. I don't think we can ever extend monadic ~ due to people using it as Boolean checker. Similarly, we can't introduce operator phrases, because people use ∘∘∘ to intentionally throw an error (they should use ⎕SIGNAL).
 

« first day (692 days earlier)      last day (1946 days later) »