Here a first aproximation. - define a list(unidimensional vector) For example the firs ten integer numbers. q) is the prompt in Q system. q) L: 1 2 3 4 5 6 7 8 9 10 - next, sum all integers q) suminteger: sum L - now, count elements of L number: count L -and to end, compute the mean q) median: suminteger%number Another way is q) (sum L)%(count L) 5.5 In Q the function to obtain integers is til q) til 10 0 1 2 3 4 5 6 7 8 9 Best, Mikel
> > > > Message: 1 > Date: Mon, 16 Jan 2012 17:11:09 +0100 > From: Kim Kuen Tang <kuent...@vodafone.de> > Subject: Re: [Jprogramming] Advantages of J over Q (aka K4/Kdb+) > To: Programming forum <programming@jsoftware.com> > Message-ID: <4f144c1d.90...@vodafone.de> > Content-Type: text/plain; charset=UTF-8; format=flowed > > > I tried to calculate the mean in K using tacit programming. > (+/%# ) !10 > But it is not working. Can you show how to program it in K? > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm