props for using { catalogue and managing a &. application in your step function.
a design principle I was aiming for is a big strength of J. What I call a
"perfect function" defined as iterative form where output is of consistent
shape/meaning as input, and where ^: can be used "separately" to
For this, I think I would have gone with:
selPrime=: #~ 1&p:
seed=: selPrime digits=: 1+i.9
step=: selPrime@,@:(,&.(10x.inv)/&>)@{@;
digits&step&.>^:a: , wrote:
>
> based on Raul's rosettacode link, but building an expaning list of left
> truncable primes, such that further search i
based on Raul's rosettacode link, but building an expaning list of left
truncable primes, such that further search is possible on future "iterations"
selPrime=: #~ 1&p:
ltrunc =: (] , ((1+i.9) (10 #. ,)"0 1 (10.inv))"0(,@:)(selPrime@:) each@:{:)
# &> sofar =: ltrunc^:6 < 3 7x
2 11 39 99 19
On Sun, Nov 20, 2022 at 12:29 PM Richard Donovan wrote:
> I guess I was expecting ‘match’ -: to be an exact compare including data type!
Yes, with numbers it's just reporting numeric equality. 1=1 regardless
of whether it's 1 apple, or 1 on the complex plane.
I guess you might use -:&(;datatype)
Thanks Raul.
Heavy stuff indeed.
I guess I was expecting ‘match’ -: to be an exact compare including data type!
> On 20 Nov 2022, at 14:58, Raul Miller wrote:
>
> digitsE=:10.^:_1 NB. Elijah's convert to digits
> digitsR=:"."0":NB. My convert to digits
> datatype digitsE 357686
digitsE=:10.^:_1 NB. Elijah's convert to digits
digitsR=:"."0":NB. My convert to digits
datatype digitsE 357686312646216567629137x
extended
datatype digitsR 357686312646216567629137x
floating
truncs=. [:~. [:10x.\. digitsR
truncs 357686312646216567629137x
3.57686e23 5.7686
Proving that I am still baffled by J!
Elijah has a different way to convert a number to its
digits than I normally use, so I set out to compare..
digitsE=:10.^:_1 NB. Elijah's convert to digits
digitsR=:"."0":NB. My convert to digits
(digitsE-:digitsR) 357686312646216567629137x
1NB.
On Sat, 19 Nov 2022, Elijah Stone wrote:
x: ". y where y is simply a string of digits will interpret those digits as a
(fixed-width) integer
(or floating-point number)
--
For information about J forums see http://www.jsoftwar
On Sat, Nov 19, 2022 at 6:47 PM 'Skip Cave' via Programming
wrote:
> Now what is the J verb that will find an n-digit integer that is still
> prime when each of the digits are removed?
I'd probably go with https://rosettacode.org/wiki/Truncatable_primes#J for that.
Thanks,
--
Raul
Thanks for all the replies.
It is fascinating to see all the different approaches to solving a problem in
J.
This forum is super helpful and friendly and always a mine of information!
> On 19 Nov 2022, at 23:54, Richard Donovan wrote:
>
> Thanks Elijah that works really well. I’m lookin
A (surely not THE) verb?:
(#~{{*/ (1 p:".) ry #~"1 -.=i.#ry =. ":y }}"0) range 100 200
111 113 117 119 131 137 171 173 179 197
Mike
On 19/11/2022 23:46, 'Skip Cave' via Programming wrote:
Interesting!
Now what is the J verb that will find an n-digit integer that is still
prime when ea
Thanks Elijah that works really well. I’m looking to extend this to primes in
other bases and try to construct and discover cases where both left and right
truncation takes place simultaneously.
> On 19 Nov 2022, at 22:04, Elijah Stone wrote:
>
> x: ". y where y is simply a string of digits
Interesting!
Now what is the J verb that will find an n-digit integer that is still
prime when each of the digits are removed?
Skip Cave
Cave Consulting LLC
On Sat, Nov 19, 2022 at 3:51 PM Richard Donovan
wrote:
> Hi
>
> I am doing experiments with large primes, in particular looking at prim
I think this is similar to your other replies, but it might still be of
interest:
1 p: ". }.^:(i.@<:@#) @: ('x',~":) 357686312646216567629137x
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
With your smaller example:
ltruncall =: }.^:(i.@<:@#) @: ('x',~":)
ltruncall 6391373x
6391373
or
(,&'x')\.&.": 357686312646216567629137x
or for vertical display
,.(,&'x')\.&.": 357686312646216567629137x
On Sat, Nov 19, 2022 at 5:04 PM Elijah Stone wrote:
>
> x: ". y where y is simply a string of digits will interpret those digits as a
> (fixed-width) integer and _then_ convert the latter
x: ". y where y is simply a string of digits will interpret those digits as a
(fixed-width) integer and _then_ convert the latter to extended-precision.
You could append an 'x', or perhaps consider the following definition:
truncs=. [:~. [:10.\. 10.^:_1 NB.equivalent to ltrunc^:a:
,.
16 matches
Mail list logo