Re: [q-lang-users] where
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-10-09 22:18:18
|
Eddie Rucker wrote: > Dr. Graef and (Mr? Dr?) Hubbard, No need to throw around titles here, we're all friendly people. ;-) That reminds me of a "Hägar the Horrible" strip in which Hägar asks his medical doctor, Dr. Zook, whether he is allowed to call him by his first name. "Yes sure," Dr. Zook replies. "So what's your first name?" asks Hägar. The reply: "Doctor." :) Ok, back on topic... > Of all of the functions in mathematics that I've ever seen, if a "where > clause" is given at the end of a piecewise function, the variables and/or > functions denoted by "where" are global to all of the "pieces." That's true, although some mathematicians (me included) occasionally use local "where" clauses in branches, too. A syntax which closely mimics this style could maybe look like this: foo X = ... Y ... where ... if ..., = ... Y ..., where Y = ...; But that's awkward to parse, since the entire collection of equations must be in memory before you can start generating code. > let N = #S - 1; > strip C S = strip C $ sub S 0 (N-1) if (S!N = C); This looks like the "let" and the following equation(s) are totally unrelated. Not a good syntax IMHO. > Another idea, so that wheres are nested: > > f X Y Z > where A = ... ; // global to all equations belonging to f > = ...; > = ...; > where B = ... ; // global to all equations below this and belonging to f > = ...; > = ...; > where C = ... where D = ...; > = ...; That's a neat idea, but still not fully general. What if you want A to be defined only in eqns #1 and #2 and B only in eqns #3 and #4? You need some kind of block structure to do that. And IMHO block structure looks messy in equational programs, at least in a free-format language like Q where you need explicit brackets to indicate the block structure. Cheers, 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 |