Problem with J function in Rosetta Code for Moebius function

36 views
Skip to first unread message

Michael Day

unread,
Jun 10, 2025, 1:28:55 PM6/10/25
to fo...@jsoftware.com
A recent message in the stream: "[Jforum] Fw: OEIS A240563 - prime
concatenation" mentions

https://rosettacode.org/wiki/M%C3%B6bius_function     (Moebius for
non-German readers!)

I noticed that Rosetta's current J proposal,
   mu=: */@:-@~:@q:
doesn't work,  because of a change in the output of q: on an array - the
right padding is
now 1s rather than 0s;  I forget how to get round the problem.)

mu DOES work ok if you force the rank to be zero:

   mu"0 >: i.20
1 _1 _1 0 _1 1 _1 0 0 1 _1 0 _1 1 1 0 _1 0 _1 0

but the Rosetta example,  without explicit rank,  now results as follows:

   mu >: i. 10 20
1

Over to Raul maybe?

Mike


--
This email has been checked for viruses by Avast antivirus software.
www.avast.com

Raul Miller

unread,
Jun 13, 2025, 5:56:40 AM6/13/25
to fo...@jsoftware.com
Ok, but you have posted the solution right there.

(Add "0 to the definition.)

That said, I really need to spin up my computer (power cord went missing during recovery from plumbing accident).

Thanks,

-- 
Raul

To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Mike Day

unread,
Jun 13, 2025, 8:08:16 AM6/13/25
to fo...@jsoftware.com
Not in the Rosetta code page!  I haven't got the Chutzpah to 
venture there.

I'd hoped to avoid "0,  but Henry's comment suggests he's 
ok with it!

Good luck with the hydrocybernetics,  aka PbI,  

Mike

Sent from my iPad

On 13 Jun 2025, at 10:56, Raul Miller <rauld...@gmail.com> wrote:



Henry Rich

unread,
Jun 13, 2025, 8:53:05 AM6/13/25
to fo...@jsoftware.com
The 9.6 ReleaseNotes https://code.jsoftware.com/wiki/System/ReleaseNotes/J9.6#Changes_to_the_J_engine says

incompatible language change: rank of q: changed to _ 0 0. With the monadic rank 0, as formerly, fill produced invalid results.

That tells you that the fix is to revert to rank 0.

Henry Rich
Reply all
Reply to author
Forward
0 new messages