I tried "trace" to see what would happen to g. The results are strange.
require'trace'
f=: 13 :'":,.p:y'
g=: 13 :'((1=+/"1 (f y)~:'' '')+((1{"1 f y)=2{"1 f y)+(3=+/"1 (f
y)=|:|.|:f y))#f y'
g i.40
2
3
5
7
11
101
131
151
f
[: ": [: ,. p:
g
((1 = [: +/"1 ' ' ~: f) + ((1 {"1 f) = 2 {"1 f) + 3 = [: +/"1 f = [: |: [:
|. [: |: f) # f
trace '[: ": [: ,. p:'
--------------- 5 Trident ----
[:
,.
p:
[: ,. p:
--------------- 5 Trident ----
[:
":
[: ,. p:
[: ": [: ,. p:
==============================
trace '((1 = [: +/"1 ' ' ~: f) + ((1 {"1 f) = 2 {"1 f) + 3 = [: +/"1 f =
[: |: [: |. [: |: f) # f'
--------------- 3 Adverb -----
+
/
+/
--------------- 4 Conj -------
+/
"
1
+/"1
--------------- 5 Trident ----
=
[:
+/"1
= [: +/"1
--------------- 6 Bident -----
1
= [: +/"1
|syntax error: executet
| t_z=. (1)(=[:+/"1)
linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Linda A
Alvord
Sent: Friday, October 16, 2015 11:31 PM
To: [email protected]
Subject: Re: [Jprogramming] Finding prime palindromes
Kip, That was a challenge! Soon someone will do it much more grcefully!
Simplifications welcome. It is all done in characters.
f=:[: ": [: ,. p:
g=:((1 = [: +/"1 ' ' ~: f) + ((1 {"1 f) = 2 {"1 f) + 3 = [: +/"1 f = [: |:
[: |. [: |: f) # f
g i.40
2
3
5
7
11
101
131
151
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of bill lam
Sent: Friday, October 16, 2015 2:05 AM
To: Programming forum
Subject: Re: [Jprogramming] Finding prime palindromes
IIRC J extended precision number implementation uses decimal base 1000 or
100000 , so that ": format is fast but calculation is slower. Things could
be the opposite if J had used 2^n base.
----------------------------------------------------------------------
For information about J forums see <http://www.jsoftware.com/forums.htm>
http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm