Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!ubc-vision!fornax!zeke From: zeke@fornax.UUCP (Zeke Hoskin) Newsgroups: comp.lang.apl Subject: mode Message-ID: <455@fornax.UUCP> Date: 29 Feb 88 18:20:32 GMT Lines: 12 Keywords: outer product The nice thing about outer-product-based mode is that it lends itself to a one-liner which you can print on a T shirt and tell people you are dressed in the latest mode. I guess a shirt is an outer product in its own right.... The bad evil nasty thing is that it is an O(Nsquared) algorithm. Here is a faster one: X <- X[gradeup X <- ,X] bool <- X =/= 1 drop X,somevalueotherthangreatestX ends <- bool / iota rho bool lengths <- ends - minus1 drop 0, ends (in origin 1) pos <- ends [ lengths iota gratest reduc lengths] mode <- X[pos]