On 6/29/07, Bruno <[EMAIL PROTECTED]> wrote:
what does the I. do?
http://www.jsoftware.com/help/dictionary/dicapdot.htm

Given a list of bits, it returns the indices of the 1s
 I. 0 0 1 1 0 1 0 1 0 0 0
2 3 5 7


And if we wanted to do as Raul told and only test odd numbers, how
do we go from 1 to 999999 jumping 2 numbers?

Er... it occurs to me that 0 (by itself) might also be a palindrome

But you could do something like 1+2*i.5e5

Note that you also need to adjust the results from I.
Maybe something like:
  0,1+2*I. _____

   +/ 1e3 #~ ((3|"0)) +. (5|"0)) i. 1e3
   NB. how do I access the current number from inside the ( ) ?

I think you want
  +/ 1e3 #~ ((3|"0])) +. (5|"0])) i. 1e3

More generally, when you are building a verb from a sequence of
verbs you usually want an ODD number of verbs inside parenthesis.

  |"0 counts as a verb

  ] counts as a verb

  Also:
  nouns (including numbers like 3 and 5 ) count like a verb IF
  every noun to its right is being treated like a verb (assuming
  there are any) AND this means that there's an even number of
  verbs to its right (more than zero).

In other words:
  3 + 5 * ]
3 and 5 are treated like verbs (constants that produce the
answer 3 and 5 respectively).  This result is itself a verb
(Note that ] is an identity function so this result verb is
equivalent to 3 5&p.)

But
  3 + 5 * 7
3 and 5 and 7 are just treated like ordinary nouns (the result is 18).

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to