[q-lang-users] where
Brought to you by:
agraef
From: Eddie R. <ed...@bm...> - 2006-10-09 13:16:17
|
Thanks Dr. Greaf for giving the reason. I will use case, cond, if then else constructs for these situations. I understand that language decisions can be difficult. Would using a "letting" statement as in the following example be bad or ugly? I'm starting to be a bit curious about language design but I don't want to waste much of your time on this. example: strip C "" = ""; strip C S letting N = #S-1 = strip C $ sub S 0 (N-1) if (S!N = C); = strip C $ sub S 1 N if (S!0 = C); = S otherwise; Eddie Eddie Rucker wrote: > Given the following script > > // strip character C from the left and right sides of a string > strip C "" = ""; > strip C S = strip C $ sub S 0 (N-1) if (S!N = C) where N = #S-1; > = strip C $ sub S 1 N if (S!0 = C) where N = #S-1; > = S otherwise; > > Is it possible to have another type of local variable defined at the end > of a list of equations that would apply to all of them? No. I actually thought about this problem before. As local variables are maintained on the expression stack, it probably wouldn't be that difficult to modify the VM to handle such shared qualifiers (as long as they share the same left-hand side). But I haven't been able to come up with a good syntax to support that in the language. So the solution is indeed to use case or if-then-else in such situations instead. 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 |