[Jprogramming] Advent of Code Day 7

2021-12-27 Thread Raul Miller
https://adventofcode.com/2021/day/7 Day 7's puzzle also had a comma separated list as its data, so again no parsing routine was necessary: sample=: 16,1,2,0,4,2,7,1,2,14 Here, you are being rescued from a whale by a bunch of crab submarines -- each number represents the position of a crab submar

Re: [Jprogramming] When an error is not an error

2021-12-27 Thread Henry Rich
Right.  When you have u :: v of try. catch., the error must persist until it has been analyzed by the error handler.  It could be removed when the error handler finishes, but it isn't. Henry Rich On 12/27/2021 11:35 AM, bill lam wrote: I believe this is the intended behaviour and a common pra

Re: [Jprogramming] When an error is not an error

2021-12-27 Thread bill lam
I believe this is the intended behaviour and a common practice. You should check for error message immediately after error occurs. > On 27 Dec 2021, at 11:38 PM, Don Guinn wrote: > > To catch errors in code that I was not aware of due to error handling such > as try-catch or whatever, I checke

Re: [Jprogramming] When an error is not an error

2021-12-27 Thread Raul Miller
It's probably worth noting here that ferase is very different from erase. The boot.ijs in my j903 does not contain ferase. But it does generate an ignored error, apparently from the 1!:4 in this block of code: f=. jpath '~config/startup.ijs' if. 1!:4 :: 0: wrote: > > To catch errors in code that

[Jprogramming] When an error is not an error

2021-12-27 Thread Don Guinn
To catch errors in code that I was not aware of due to error handling such as try-catch or whatever, I checked the value of the error message (13!:12''). But it found the error message is set even though no error was signaled. Below is a new J session. 13!:12'' |interface error | ferase fs |[-1

Re: [Jprogramming] The bind conjunction

2021-12-27 Thread 'Pascal Jasmin' via Programming
Untested but, Bind =: ]: @ ("_) On Sunday, December 26, 2021, 04:45:08 p.m. EST, bill lam wrote: The conjunction in stdlib   bind 2 : 'u@(v"_)' How to write it without explicit definition, but using trains of conjunctions and adverbs resurrected in j903?

Re: [Jprogramming] Advent of Code Day 6

2021-12-27 Thread 'Michael Day' via Programming
Yes, a nice insight,  I suppose,  but only nice,  and by no means necessary! Many Project Euler problems require this sort of thing in the tool-box! Also,  some sort of counting of cases is often nearly essential for PE. One of my finite arithmetic routines,  written pre-{{ ... }} NB. Matrix x t

Re: [Jprogramming] Advent of Code Day 6

2021-12-27 Thread Raul Miller
That's a really good insight. Conceptually, this would be 1 (<0 6)}(=/1|.])i.9 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 But we want to multiply on the right (for ^:) instead

Re: [Jprogramming] Advent of Code Day 6

2021-12-27 Thread 'Mike Day' via Programming
Yes, a 9x9 Boolean matrix with an offset 1s diagonal and an extra 1. It might have been worth using the high-power squaring technique, if the power were really large, but for 256 I just took the direct 256th power. Cheers, Mike Sent from my iPad > On 27 Dec 2021, at 06:17, Raul Miller wro