Help please

36 views
Skip to first unread message

Richard Donovan

unread,
Jul 24, 2025, 1:09:24 PM7/24/25
to forum
I need a function to concatenate a series of digits.

I tried:

concat=:4 : 'x:". (":x),(":y)'"0

Try with first 11 primes:

concat/p:i.11
235711131719232931
NB. Looks good

NB. But...
concat/p:i.12
23571113171923292160
  concat/p:i.12x
23571113171923292160
NB. These fail

Thanks,
Richard

Don Guinn

unread,
Jul 24, 2025, 1:29:25 PM7/24/25
to fo...@jsoftware.com
This should work; however, it doesn't need the / or rank defined to 0. Don't know if you require them.

{{;":&.>y}}p:i.12

23571113171923293137


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

Henry Rich

unread,
Jul 24, 2025, 1:30:24 PM7/24/25
to fo...@jsoftware.com
23571113171923293137  exceeds integer, add x

Henry Rich

Mike Day

unread,
Jul 24, 2025, 1:35:12 PM7/24/25
to fo...@jsoftware.com
As Henry says;  this minor change to your fn works for 12 primes:
      concat=:4 : 'x:". ''x'',~(":x),(":y)'"0

   concat/p:i.12. NB.  No need to extend the input type for these primes
23571113171923293137

OK?

Mike

Sent from my iPad

On 24 Jul 2025, at 18:09, Richard Donovan <rsdo...@hotmail.com> wrote:


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

Richard Donovan

unread,
Jul 24, 2025, 3:00:31 PM7/24/25
to fo...@jsoftware.com
  concat/p:i.12x
23571113171923292160
NB. These fail

Hi Henry! I already tried adding x with no luck, as above

Thanks, Richard

From: fo...@jsoftware.com <fo...@jsoftware.com> on behalf of Henry Rich <henry...@gmail.com>
Sent: 24 July 2025 18:30
To: fo...@jsoftware.com <fo...@jsoftware.com>
Subject: Re: [Jforum] Help please
 

Richard Donovan

unread,
Jul 24, 2025, 3:07:04 PM7/24/25
to fo...@jsoftware.com
That did the trick! Thanks all

From: 'Mike Day' via forum <fo...@jsoftware.com>
Sent: 24 July 2025 18:34

To: fo...@jsoftware.com <fo...@jsoftware.com>
Subject: Re: [Jforum] Help please

Michael Day

unread,
Jul 24, 2025, 4:29:28 PM7/24/25
to fo...@jsoftware.com

... though I do rather prefer this variant inspired by Don Guinn's suggestion:

   concatx =: {{'x',~' ' -.~;y}}&.":
   concatx p:1000+i.10
7927793379377949795179637993800980118017


Don's suggested fn returns a string/literal,  but the under neatly returns 

the input to extended,  even though the input is integer. 


Cheers,


Mike


Virus-free.www.avast.com

Devon McCormick

unread,
Jul 24, 2025, 5:42:44 PM7/24/25
to fo...@jsoftware.com
Your numbers look like they start out concatenated but you appear to want to change their type.  Why not something like this:

   ' ' (([ -.~ [: ": ])"0 1) p:i.10
2357111317192329
   ' ' (([ -.~ [: ": ])"0 1) p:i.50
2357111317192329313741434753596167717379838997101103107109113127131137139149151157163167173179181191193197199211223227229

   


--

Devon McCormick

Flâneur


Michael Day

unread,
Jul 24, 2025, 6:00:50 PM7/24/25
to fo...@jsoftware.com
Well - Richard Donovan's original cri de coeur concerned
loss of precision of the output integer representation of the concatenation,  
not the literal.  He wants an integer scalar output for an integer vector input.
What's wrong with that requirement?
Thanks,
Mike

Devon McCormick

unread,
Jul 24, 2025, 6:31:49 PM7/24/25
to fo...@jsoftware.com
So something like this:

   ".'x',~' ' (([ -.~ [: ": ])"0 1) p:i.50
2357111317192329313741434753596167717379838997101103107109113127131137139149151157163167173179181191193197199211223227229
   ".'x',~' ' (([ -.~ [: ": ])"0 1) p:i.10
2357111317192329

   
?

Michael Day

unread,
Jul 24, 2025, 7:08:23 PM7/24/25
to fo...@jsoftware.com

Yes,  I think that also fits his requirements

M

Don Guinn

unread,
Jul 25, 2025, 10:29:50 AM7/25/25
to fo...@jsoftware.com

concat=:,&":

concat/p:i.20

235711131719232931374143475359616771

Henry Rich

unread,
Jul 25, 2025, 1:46:33 PM7/25/25
to fo...@jsoftware.com
Bravo. 

This appends on the left, which is not in place and thus has quadratic performance.  For long strings it's worthwhile to append on the right:

   ,~&":/@|. p: i. 20
235711131719232931374143475359616771

Henry Rich


Don Guinn

unread,
Jul 25, 2025, 6:46:25 PM7/25/25
to fo...@jsoftware.com
It wasn't originally stated that the result should be extended and not literal; however, this makes the result extended and keeps your suggestion linear.

>:('x',~,~)&.":/@|. p: i. 20

235711131719232931374143475359616772

Reply all
Reply to author
Forward
0 new messages