Re: [Jprogramming] Advent of Code Day 19

2022-01-11 Thread Stefan Baumann
On Mon, Jan 10, 2022 at 8:20 PM Raul Miller wrote: > Hmm... > > I like your use of reference rotations R. And, your approach to > combining what were a bunch of different steps in mine looks nice. (It > takes a bit longer this way, but for this puzzle the extra time I > needed to code up my appro

[Jprogramming] Parsing {{ }}

2022-01-11 Thread 'Mike Day' via Programming
For Henry I expect: as I share code between J903 on the laptop and J701 on this iPad, I’ve been avoiding the use of {{ }} objects. (My iPad can’t support Ian’s new J902.) But I was just wondering about adding a routine to the J701 start.ijs script to parse a J903 script translating direct def

Re: [Jprogramming] Parsing {{ }}

2022-01-11 Thread Raul Miller
If you avoid nested {{ }} blocks, 5!:5 would do this. In other words, this works: mean=: {{ (+/ % #) y}} 5!:5<'mean' 3 : '(+/ % #) y' But this would be useless for your purposes: mean=: {{ {{x + y}} {{u/}} {{x % y}} {{#y}} }} 5!:5<'mean' 3 : '{{ x + y }} {{ u/ }} {{ x % y }} {{ #

Re: [Jprogramming] Parsing {{ }}

2022-01-11 Thread Henry Rich
There is nothing I know of that does what {{ }} does.  But Raul's idea is pretty close.  As he notes, it fails for nested {{ }} (there is much code that expects the result of 5!:5 <'explicitname' to have the form m : string, but nested {{ }} seemed OK). Henry Rich On 1/11/2022 9:19 AM, Raul M

Re: [Jprogramming] Parsing {{ }}

2022-01-11 Thread 'Mike Day' via Programming
Oh well. I thought you might have test-bedded these forms in J before moving to C, Henry, in which case there might have been a readymade J script! As for Raul’s suggestion, that’s fine, but, in as far as I have copied across to J701, just typing the verb’s name in the session reveals the n

Re: [Jprogramming] Parsing {{ }}

2022-01-11 Thread 'robert therriault' via Programming
Hi Mike, You may not know, but there is a new J app that Ian Clark has developed called J901 (although it is running a version of J903 I believe) that supports {{ }} You can find it in the app store for the iPad or the iPhone. The interface is slightly different, but it is really good. Cheers,

Re: [Jprogramming] Advent of Code Day 21

2022-01-11 Thread 'Michael Day' via Programming
I think it's easier to post my code than to try answering your question. I've run successfully this in a new session, so I think it's self-contained. Apologies for the verbose code - it's as I wrote it,  and I haven't attempted to polish it for presentation here.  The function "part2" , not s

Re: [Jprogramming] Parsing {{ }}

2022-01-11 Thread 'Michael Day' via Programming
Thanks, Bob - yes,  I do know.  Ian gave up hoping to keep J901 compatible with my iOS 11,  later iOS 12. My iPad is too old to support the later versions of iOS which support his J901 app. Liz (my email address's other half!)  does have it on her iPad,  but I don't want to take over her tablet!

[Jprogramming] How to add standard deviation to multiple timings?

2022-01-11 Thread Devon McCormick
Hi, I sometimes time expressions with a left argument of something like 10 or 100, e.g. "(100) 6!:2 'singlePair testSP0'". This gives me an average time for the multiple iterations. It would be nice to be able to get the standard deviation of the multiple invocations as well. I can do this myse

Re: [Jprogramming] How to add standard deviation to multiple timings?

2022-01-11 Thread 'Pascal Jasmin' via Programming
Your approach seems good.  You can also do:  (i.10) timex '+/i.1' Regarding the domain of timing code, I'd be surprised, and so curious, if the standard deviation wasn't a "fixed percentage" of average time, with a bias for quickest functions having the highest standard dev as a percentage

Re: [Jprogramming] How to add standard deviation to multiple timings?

2022-01-11 Thread Devon McCormick
Thanks for the tip - it's a cleaner way to accomplish what I want. I'm not sure about your standard deviation supposition or maybe I don't understand what you're saying. I think you can get arbitrarily large standard deviations by supplying arguments with large standard deviations, e.g. usus #

[Jprogramming] Equal result unexpected

2022-01-11 Thread Pawel Jakubas
Thanks Raul for all great hints (not all yet absorbed by me, for example the usage of {{ }}, but will in time, when it becomes clear to me why it is better). For the record. I have documented all ways suggested in this thread to have always at my disposal: https://github.com/paweljakubas/j-random-

Re: [Jprogramming] Advent of Code Day 21

2022-01-11 Thread Raul Miller
Ah, gotcha -- thanks! -- Raul On Tue, Jan 11, 2022 at 11:23 AM 'Michael Day' via Programming wrote: > > I think it's easier to post my code than to try answering your question. > I've run successfully this in a new session, so I think it's > self-contained. > > Apologies for the verbose code -

Re: [Jprogramming] Equal result unexpected

2022-01-11 Thread Raul Miller
{{ }} is just a convenience. I like it because I do not have to concern myself with doubling quotes when using the expressions in string contexts. Thanks, -- Raul On Tue, Jan 11, 2022 at 3:45 PM Pawel Jakubas wrote: > > Thanks Raul for all great hints (not all yet absorbed by me, for example

[Jprogramming] Advent of Code Day 22

2022-01-11 Thread Raul Miller
https://adventofcode.com/2021/day/22 The day 22 puzzle was about "rebooting the reactor". Here, we have a sequence of steps which consist of turning on, or off, a rectangular cuboid in our coordinate system. In this puzzle each x,y,z coordinate value was referred to as a cube. s=: sample=:{{)n o

Re: [Jprogramming] Advent of Code Day 22

2022-01-11 Thread 'Mike Day' via Programming
Briefly for now, as the pub quiz went on far too long & it’s midnight... I hope my hint wasn’t too much of a spoiler; unintended if it was. My insight was somewhat mathematical, and is similar in a way to the Moebius transform. I worked through a 2-d analogue looking at intersecting rectangles

Re: [Jprogramming] Advent of Code Day 22

2022-01-11 Thread Raul Miller
Huh... well... I suspect you are talking more about https://en.wikipedia.org/wiki/M%C3%B6bius_inversion_formula than about https://en.wikipedia.org/wiki/M%C3%B6bius_transformation And, maybe specifically https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle That said, I'm not yet s