rxapply question

28 views
Skip to first unread message

Jörg Sommrey

unread,
Aug 20, 2026, 2:36:31 PMAug 20
to fo...@jsoftware.com
Hello all,

when using "rxapply" within the body of an explicit verb with a
locally defined verb as its operand, I get an "value error".

Example:

require 'regex'

foo =: 4 : 0
bar =. ,&'1'
x bar rxapply y
)

'a' foo 'abcde'
|value error: bar
| r=. u&.>mat rxfrom y

Obviously "rxapply" accesses its operand as "u". Shouldn't this be
"u." instead?

Using a locally modified version of "rxapply" solves my problem, but I
don't know if this change would cause a regression anywhere else.

A slightly related question:
The nuvoc documentation shows a conjunction "Fix (partial) f:", but
using it produces a "spelling error". Has it been removed or is it
not yet implemented?

Best regards,
-jo

Joshua Y

unread,
Aug 21, 2026, 7:37:20 AMAug 21
to forum, Jörg Sommrey
I can replicate your issue on the J Playground and Juno, but it works fine locally on my Linux machine (returns "a1bcde").

The part that's failing is a call to `jpcre2_compile` which is a DLL call into libpcre

   jpcre2_compile_jregex_
'"libpcre2-8.so" pcre2_compile_8 * *c x i *i *x *'&(15!:0)

My guess is this is not available on the WASM version of J.

With the assumption that you're using the WASM version...
The latest version available is 9.7.1 on the Playground, and 9.8.0-beta1 on Juno.
The `f:` Conjunction is brand new, only added in the most recent beta 9.8.0-beta6.

Jörg Sommrey

unread,
Aug 21, 2026, 9:48:50 AMAug 21
to fo...@jsoftware.com

On Fri 21 Aug 2026 01:37:20 PM CEST, Joshua Y <josh...@gmail.com> wrote:

> ... but it works fine
> locally on my Linux machine (returns "a1bcde").

This is *very* strange. I hadn't expected it to work anywhere. It
would mean, that in the following example both "squares" and
"squaresdot" are working on your platform:

values =: 1 : 0
r =. u y
y ,. r
)

valuesdot =: 1 : 0
r =. u. y
y ,. r
)

squares =: 3 : 0
square =. *:
square values y
)

squaresdot =: 3 : 0
square =. *:
square valuesdot y
)

squaresdot i.5
0 0
1 1
2 4
3 9
4 16
squares i.5
|value error: square
| r=. u y

"values" has exactly the same problem as "rxapply" and "valuesdot" has
the fix I proposed.
Perhaps another brand new change in the J engine?
BTW: I'm on Linux, too.

> The `f:` Conjunction is brand new, only added in the most recent beta
> 9.8.0-beta6.

Thanks, looks very interesting.

Best regards,
-jo

>
> On Friday, 21 August 2026 at 04:36:31 UTC+10 Jörg Sommrey wrote:
>
>> Hello all,
>>
>> when using "rxapply" within the body of an explicit verb with a
>> locally defined verb as its operand, I get an "value error".
>>
>> Example:
>>
>> require 'regex'
>>
>> foo =: 4 : 0
>> bar =. ,&'1'
>> x bar rxapply y
>> )
>>
>> 'a' foo 'abcde'
>> |value error: bar
>> | r=. u&.>mat rxfrom y
>>
>> Obviously "rxapply" accesses its operand as "u". Shouldn't this be
>> "u." instead?
>>
>> Using a locally modified version of "rxapply" solves my problem, but I
>> don't know if this change would cause a regression anywhere else.
>>
>> A slightly related question:
>> The nuvoc documentation shows a conjunction "Fix (partial) f:", but
>> using it produces a "spelling error". Has it been removed or is it
>> not yet implemented?
>>
>> Best regards,
>> -jo
>>
>
> To unsubscribe from this group and stop receiving emails from it,
> send an email to forum+un...@jsoftware.com.


Jose Mario Quintana

unread,
Aug 21, 2026, 11:10:19 AMAug 21
to fo...@jsoftware.com
Try,

foo =: 4 : 0
   x  ,&'1'  rxapply y
)

or

foo =: 4 : 0

bar =. ,&'1'

x bar f. rxapply y

)


if you prefer.


Jörg Sommrey

unread,
Aug 21, 2026, 11:58:53 AMAug 21
to fo...@jsoftware.com
I am aware of these possibilities, but they are not very helpful in
what I want to achieve.

Consider Perl's "s///gr" operator, e.g. "s/-(\d+)-+(\d+)-/$2-$1/gr".
I try to emulate it in J like this:

subst_xchg =: 3 : 0
rh =. rxcomp '-(\d+)-+(\d+)-'
xchg =. [: (] , '-' , [)&>/ ] rxfrom~ (rh;1 2) rxmatch ]
rh xchg rxapply y
)

This is a simplification again. In my real use case, the verb that
acts as the operand to rxapply is again assembled from other local
verbs. Inserting everything into the rxapply sentence would make it
completely unreadable.

Which leads to option 2: fix the verb. Sadly, this seems not to be
possible. I don't know why, but in my installation I get:

rh =. rxcomp '-(\d+)-+(\d+)-'
xchg =. [: (] , '-' , [)&>/ ] rxfrom~ (rh;1 2) rxmatch ]
xchg '-12--34-'
34-12
xchg f. '-12--34-'
|value error: regcomp
| regcomp p

This brings me to the question about "f:". Maybe it could help here.

For me the best solution would be fixing "rxapply" to use "u." instead of "u".
The only working alternative is to declare the participating verbs as
global. I just dislike that.

Best regards,
-jo

On Fri 21 Aug 2026 05:10:00 PM CEST, Jose Mario Quintana

Henry Rich

unread,
Aug 21, 2026, 12:04:44 PMAug 21
to forum
I thought we had made this change recently. Do you have the most recent version?

Henry Rich

Jörg Sommrey

unread,
Aug 21, 2026, 12:36:50 PMAug 21
to fo...@jsoftware.com

On Fri 21 Aug 2026 06:04:30 PM CEST, Henry Rich <henry...@gmail.com> wrote:

> I thought we had made this change recently. Do you have the most
> recent version?

No. I havn't yet upgraded from Debian oldoldstable to a newer release.
Due to glibc dependencies I'm stuck with J9.6 at the moment.
It would be great if the problem had been fixed in J9.8 and I'll just
patch "rxapply" on my dinosaur system.

Best regards,
-jo

Henry Rich

unread,
Aug 21, 2026, 2:01:03 PMAug 21
to fo...@jsoftware.com
I'm not 100% sure this fix has been released yet.  Try it before you
rely on it.

Your error in (xchg f.) arises because f. replaces rxmatch with its
definition, losing the effect of the locative, and making rxcomp is
undefined in the anonymous body.

You would need a way to fix private names without fixing public names. 
As luck would have it, (u f: n) will support this in the next beta.

Henry Rich

Jörg Sommrey

unread,
Aug 21, 2026, 4:10:36 PMAug 21
to fo...@jsoftware.com

On Fri 21 Aug 2026 08:00:58 PM CEST, Henry Rich <henry...@gmail.com> wrote:

> I'm not 100% sure this fix has been released yet.  Try it before you
> rely on it.
Actually it is fixed in the current J9.8 beta.

>
> Your error in (xchg f.) arises because f. replaces rxmatch with its
> definition, losing the effect of the locative, and making rxcomp is
> undefined in the anonymous body.
Thank you for the explanation. I still need to learn a lot.

>
> You would need a way to fix private names without fixing public
> names.  As luck would have it, (u f: n) will support this in the
> next beta.
I've hoped this would be the purpose of "f:".

Maybe I should tell something about myself before you take my
contribution to this forum too serious:
I am a retired software developer. I was paid to write Java
applications but in my mind I always felt as a Perl programmer.

One year ago I didn't even know that J existed. One of my hobbies is
to solve "The Weekly Challenge", initially in Perl only. Incidentally
I discovered J as a language supporting mixed based number
representations and from then I started learning J and trying to solve
the challenges in J. Nothing I do in J has a serious background.

I am deeply impressed by this language and its community. Thank you
very much for this gem.

Best regards,
-jo
Reply all
Reply to author
Forward
0 new messages