Re: [q-lang-users] Bug? New 'where' syntax
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2007-05-26 05:50:11
|
Eddie Rucker wrote: >> (3) collections of several 'if' and 'where' clauses are processed in a >> "backward" fashion, consider e.g.: if X>Y where Y=bla Z where Z=foo X. > > (3) takes some getting use to. For example: > > func [] = []; > func [L|Ls] > where (X1,X2) = Ws > where (W|Ws) = L: > = [- X1 * X2] ++ func Ls if W > 0; > = [0] ++ func Ls if W = 0; > = [X1 * X2] ++ func Ls if W < 0; Note that different definitions inside a single 'where' clause are processed from left to right, so you could also write: func [L|Ls] where (W|Ws) = L, (X1,X2) = Ws: = [- X1 * X2] ++ func Ls if W > 0; But I have to admit that foo X where Y = bar X: = Y/2; doesn't read very well. I can live with it, since I read it as: "Define foo X. First case, where Y = bar X: result is Y/2". Maybe you can get used to it. But for native English speakers it might be too much to bear. Ouch. Maybe we need an entirely new qualifier syntax which works on both sides of an equation. Any ideas, anyone? Native speakers to the rescue! :) Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |