Path: utzoo!utgpu!watserv1!watmath!att!occrsh!uokmax!apple!usc!chaph.usc.edu!usc.edu!news From: news@usc.edu Newsgroups: comp.lang.apl Subject: Re: Dyalog question Message-ID: <11930@chaph.usc.edu> Date: 12 Sep 90 01:21:07 GMT References: <7273@umd5.umd.edu> Sender: news@chaph.usc.edu Reply-To: raulmill@usc.edu Organization: University of Southern California, Los Angeles, CA Lines: 48 Nntp-Posting-Host: girtab.usc.edu In-reply-to: jph@suns.UMD.EDU's message of 11 Sep 90 07:00:01 GMT Originator: news@girtab.usc.edu In article <7273@umd5.umd.edu> jph@suns.UMD.EDU (J. Patrick Harrington) writes: 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. ... 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. First off, I'm not a Dyalog user, so maybe I should just shut up... However, normally, the way you 'fill short rows with zeros' is with an overtake. e.g. on line [6] ONE: Z[I;] <- J take execute .... As for discarding non-numeric comments, well.. that depends on what a comment is, but try: [5.5] B <- J reshape 0 [6] ONE: T <- ss(ss(ss(I pick R)'-' '@')'e' 'E')'+' '' [6.1] ->(~ v/ '0123456789' element_of T)/NEXT [6.2] ->(~ ^/ T element_of '@0123456789E ')/NEXT [6.3] B[I ] <- 1 [6.4] Z[I;] <- J take execute T [7] NEXT: I <- I + 1 [8] ->(N ge I)/ONE [9] Z <- B /[1] Z note that element_of is the old familiar epsilon, and that ~ v/ may be done more quickly as ~ 1 element_of, and that ~ ^/ may be done more quickly as 0 element_of 'nuf said