Yes this appears to be what I need.

I think in APL  I used / in this way but for some reason

1 0 1 0 1 / 'abcde'
|domain error
|       1 0 1 0 1/'abcde'
   1 0 1 0 1 / 'abcde'
|domain error
|       1 0 1 0 1/'abcde'
   1 0 1 0 1 / 'abcde'
|domain error
|       1 0 1 0 1/'abcde'
   1 1 0 0 1/i. 5
|domain error
|       1 1 0 0 1/i.5
   1 1 0 1 1# 'abcde'
abde
   1 0 1 0 1# i. 5
0 2 4

If there is a hint about this in the Volcabulary, somehow I missed it. I expected that to be the easiest place to find out what a particular symbol as used for but apparently not--here is the entry:

# Tally • Copy
#. Base 2 • Base
#: Antibase 2 • Antibase

If the arguments have an equal number of items, then x#y copies +/x items from y, with i{x repetitions of item i{y . Otherwise, if one is an atom it is repeated to make the item count of the arguments equal.

The complex left argument a j. b copies a items followed by b fills. The fit conjunction provides specified fills, as in #!.f .

I believe there is probably a good reason why J does not map this function to the verb / and does map it to # but right now I cannot tell what that reason would be. If someone knows and would like to enlighten me I would appreciate it and feel free to mock me for being so dense while you are about it.

Thanks
Donna


On Sat 7/Oct/2006, at 7:38 PM, Dan Bron wrote:

I don't know what you mean, but filtering and selection can be accomplished in many ways in J. The most fundamental, in my
opinion, is  #  .  To wit:

           ] some_numbers =. 5 ? 10
        2 7 1 9 5

           greater_than_4 =. 4 < ]
        
           ] mask =. greater_than_4 some_numbers
        0 1 0 1 1
        
           mask # some_numbers
        7 9 5
        
           (#~ 4 < ]) some_numbers
        7 9 5


Here, mask was a boolean list which indicated which elements of some_numbers to keep and which to discard. That is, told #
which elements to filter.

My mnemonic for was (when I started), that # looks like a little net or sieve. When you put things in a net, you lose whatever lies over a hole, and you keep everything else. In a boolean list, the 0s (little circles, absences) are the holes, and the 1s
the lines (presences), which together make up the net.

-Dan


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

Reply via email to