Wow, thanks to all! So many, useful, replies. Thanks.
@Tracy Harms: I was using it to solve problem 187 of Project Euler (
http://projecteuler.net/index.php?section=problems&id=187 ). I saw
many users solving those problems in J and I got interested in how J
solve some problem easily.
I came out with:
+/2...@q:1+i.1e5
which is not good enough to compute up to 1e8 yet as the problem asks,
anyway I'm still learning.
After the 2= test I have an array with only 0 and 1, summing them tell
me how many valid values I found, is this approach correct? I'm new to
pure functional programming (other than J), is there a better method?
I have an other question, I'll post it here, tell me if you prefer me
to start a new thread instead.
I'm used to reason with non-functional programming, I was thinking
about iterating all combination of primes such that their product is
less than say 100, in python i'd do something like:
count = 0
for a in prime_generator(start = 2):
for b in prime_generator(start = a):
if a*b > 100: break
count += 1
So I'm trying to produce in J a list of number made of 2*2 2*3 2*5 2*7
... 2*47 3*3 3*5 3*7 ... 3*31 5*5....
I wasn't able to find a good way to do it, i tried:
z=:p:i.5
z*/z
4 6 10 14 22
6 9 15 21 33
10 15 25 35 55
14 21 35 49 77
22 33 55 77 121
what I'd need from this matrix is an array containing the elements on
its high (or low) triangle, diagonal included, as the rest are
duplicated items. Any good way to do this?
Thank you all, again!
--
Andrea
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm