Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!haven!umd5!suns.UMD.EDU!jph From: jph@suns.UMD.EDU (J. Patrick Harrington) Newsgroups: comp.lang.apl Subject: Dyalog question Message-ID: <7273@umd5.umd.edu> Date: 11 Sep 90 07:00:01 GMT Sender: news@umd5.umd.edu Reply-To: jph@suns.UMD.EDU (J. Patrick Harrington) Organization: Univ. of Maryland @ College Park, Astronomy Lines: 28 Thanks for the replies - I'm glad to see there are a few Dyalog users on the net, and that I was not overlooking something much simpler. I first tried the "each" operator, which did work for positive numbers without exponents. For the more general case, I've only been able to do the conversion line by line. The following function does what I need at present. Let the unix file 'NAME' have N rows with J numbers in each (assuming no more than 10000 rows); then "UR" puts the numbers into the array Z of shape N by J: Z <- UR NAME;R;N;J;I [1] 'unixfiles'[]SH'unixfiles' 'open' 'tread' 'close' [2] 'xutils'[]SH'xutils' 'ss' [3] R <- 2 tread (N <- open NAME) 10000 & close N [4] J <- 1 cel dc shape execute ss(ss(ss(dc R[1])'-' '@')'e' 'E')'+' '' [5] N <- dc shape R & Z <- N J reshape 0 & I <- 1 [6] ONE: Z[I;] <- execute ss(ss(ss(I pick R)'-' '@')'e' 'E')'+' '' [7] ->(N ge I <- I+1)/ONE where dc=disclose, @=high minus, ge=greater or equal, &=diamond, and cel=ceiling. Line [5] looks at the first row to find the number of columns in the file. Still, it would be nice to have something "smarter", that would fill short rows with zeros, discard non-numeric comments, etc. J.P. Harrington jph@astro.umd.edu