# q: 453
2
   # q: 32
5
   #...@q: 453 32
2 5

#...@q: 1+i.10
0 1 1 2 1 2 1 3 2 2

@ is a conjunction called composition which results in a new verb
which applies the verb on its left (#) after applying the verb to its
right (q:).

See also @: which you do not want to use here.

To eliminate zeroes use -.
1 0 2 0 3 0 0 4 5 0 0 6 -. 0
1 2 3 4 5 6

2009/8/6 Andrea Ambu <[email protected]>:
> Hi all, this is my first post here. I'm Andrea, an Italian student and
> I'm trying to learn J, I'm very new to it. Be patient please :)
>
> I've a list of simple questions:
>
> 1 - Counting elements line by line.
>
> I'm looking for the number of prime factors of a list of numbers
> If I was going for a single number i'd do:
>
>>   #q:8
>> 3
>
> which is perfect. But I can't do it for a list of numbers, as q:1+i.10
> returns a matrix and # returns the number of rows. How can I get the
> number of prime factor line by line?
>
> 2 - Zeroes matter when counting.
>
> How can I eliminate items with value 0 from a list?
> i.e. given  1 0 2 0 3 0 0 4 5 0 0 6   i'd like to obtain 1 2 3 4 5 6
>
> Thanks for your time and replies in advance.
>
> --
> Andrea
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to