You are so close! Just use the #/.~ with some special glue ;"1 0 to join the nub ~. to the count.
(~. ;"1 0 ( #/.~))test ┌────────────┬─┐ │0 │1│ ├────────────┼─┤ │1 │1│ ├────────────┼─┤ │8 │1│ ├────────────┼─┤ │27 │1│ ├────────────┼─┤ │46 │1│ ├────────────┼─┤ │125 │2│ ├────────────┼─┤ │126 │1│ ├────────────┼─┤ │334 │1│ ├────────────┼─┤ │279 │1│ └────────────┴─┘ cheers, bob On 2011-10-11, at 4:41 PM, David Vaughan wrote: > Thanks, but there seems to be loads of ' ' after the digits: > > ]test=.10{.p 3^~i.9000x > 0 > 1 > 8 > 27 > 46 > 125 > 126 > 334 > 125 > 279 > '125'-:"1 test > 0 0 0 0 0 0 0 0 0 0 > '125 '-:"1 test > 0 0 0 0 0 1 0 0 1 0 > > On 12 Oct 2011, at 00:04, Ric Sherlock wrote: > >> You are trying to do something like: >> '12345' = 7 5$'12345' >> |length error >> | '12345' =7 5$'12345' >> >> J doesn't know how to reconcile the list of 5 items with the list of 7 >> items (each of which are 5 items long). >> You could do: >> '12345' ="1 ] 7 5$'12345' >> 1 1 1 1 1 >> 1 1 1 1 1 >> 1 1 1 1 1 >> 1 1 1 1 1 >> 1 1 1 1 1 >> 1 1 1 1 1 >> 1 1 1 1 1 >> >> But I suspect you want something more like: >> '12345' -:"1 ] 7 5$'12345' >> 1 1 1 1 1 1 1 >> >> >> >> >> On Wed, Oct 12, 2011 at 11:51 AM, David Vaughan >> <purpleblue...@googlemail.com> wrote: >>> Thanks. >>> >>> I'm trying to get those items which are equal to a specific string, but I >>> keep getting length errors, and I'm not quite sure what's going on: >>> >>> p=.(/:~)&":"0 >>> (#~ '012334556789' = ]) p 3^~i.9000x >>> |length error >>> | (#~'012334556789'=])p 3^~i.9000 >>> >>> I've used a similar tacit verb when dealing with numbers, but I guess this >>> not working has to do with the fact that it's on strings. >>> >>> On 11 Oct 2011, at 23:18, Henry Rich wrote: >>> >>>> (/: 1&{"1) >>>> >>>>> ./@>@:(1&{"1) >>>> >>>> there are other ways too >>>> >>>> Henry Rich >>>> >>>> On 10/11/2011 6:14 PM, David Vaughan wrote: >>>>> I have strings and a numbers in adjacent boxes, like so: >>>>> >>>>> ┌─────────┬─┐ >>>>> │0 │1│ >>>>> ├─────────┼─┤ >>>>> │1 │1│ >>>>> ├─────────┼─┤ >>>>> │8 │1│ >>>>> ├─────────┼─┤ >>>>> │27 │1│ >>>>> ├─────────┼─┤ >>>>> │46 │1│ >>>>> ├─────────┼─┤ >>>>> │125 │2│ >>>>> ├─────────┼─┤ >>>>> │126 │1│ >>>>> ├─────────┼─┤ >>>>> │334 │1│ >>>>> ├─────────┼─┤ >>>>> │279 │1│ >>>>> ├─────────┼─┤ >>>>> │0001 │1│ >>>>> └─────────┴─┘ >>>>> >>>>> How can I do things like sort or>./ on only the second box of each row? >>>>> ---------------------------------------------------------------------- >>>>> For information about J forums see 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 >> ---------------------------------------------------------------------- >> For information about J forums see 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