Here is another way. <:#/.~a,b
This produces a zero count for values of b not in a. On Wed, Dec 11, 2013 at 11:30 AM, Ni Bo <[email protected]> wrote: > Thank you. Will try it later on the data. > > Nick > Am 11.12.2013 20:16 schrieb "Kenneth Lettow" <[email protected]>: > > > How about > > > > a=: 1 2 3 4 5 6 > > b=: 14 3 2 5 6 2 1 1 2 3 4 2 3 > > +/"1 (a=/b) > > 2 4 3 1 1 1 > > {:"1 /:~(~.,#)/.~(#a)-.~a i. b > > 2 4 3 1 1 1 > > NB. make it a verb > > doit=: 4 : '{:"1 /:~(~.,#)/.~(#x)-.~x i. y' > > a doit b > > 2 4 3 1 1 1 > > NB. larger args > > a=: >: i.100000 > > b=: ?100000000$200000 > > a doit b > > 516 504 497 519 505 501 498 495 485 495 503 534 500 508 482 496 495 512 > 518 > > 558 484 491 487 527 497 510 490 477 491 474 506 475 457 461 426 ... > > ts=: 6!:2,7!:2@] NB. time & space > > ts'a doit b' > > 8.0017 3.84198e9 > > > > > > > > > > On Wed, Dec 11, 2013 at 12:11 PM, Ni Bo <[email protected]> wrote: > > > > > Hi, > > > > > > I'm using the data off the kaggle competition to learn some j. > > > > > > This simple code works for these short strings: > > > a=:1 2 3 4 5 6 > > > b=:14 3 2 5 6 2 1 1 2 3 4 2 3 > > > +/"1 (a=/b) > > > 2 4 3 1 1 1 > > > > > > But if I try it for longer strings #a 250 and #b 1 000 000 I get out of > > > memory. > > > > > > Can you please help me with a better way? > > > > > > Nick > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > > > > > > > -- > > *Kenneth Lettow* > > *Director of Web Analytics and Market Intelligence* > > *ThomasNet.com* > > Five Penn Plaza, 8th Floor > > New York, NY 10001 > > *: [email protected] > > *(*: 212.290.8713 > > www.thomasnet.com > > ---------------------------------------------------------------------- > > 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
