q-lang-users Mailing List for Q - Equational Programming Language (Page 29)
Brought to you by:
agraef
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(3) |
Feb
(27) |
Mar
|
Apr
(4) |
May
(11) |
Jun
(5) |
Jul
(5) |
Aug
(6) |
Sep
(15) |
Oct
(28) |
Nov
(8) |
Dec
|
2005 |
Jan
(9) |
Feb
(5) |
Mar
(10) |
Apr
(43) |
May
(8) |
Jun
(31) |
Jul
(45) |
Aug
(17) |
Sep
(8) |
Oct
(30) |
Nov
(2) |
Dec
(6) |
2006 |
Jan
(4) |
Feb
(20) |
Mar
(1) |
Apr
|
May
(92) |
Jun
(179) |
Jul
(26) |
Aug
(65) |
Sep
(36) |
Oct
(38) |
Nov
(44) |
Dec
(68) |
2007 |
Jan
(11) |
Feb
(25) |
Mar
(37) |
Apr
(7) |
May
(83) |
Jun
(77) |
Jul
(44) |
Aug
(4) |
Sep
(28) |
Oct
(53) |
Nov
(12) |
Dec
(21) |
2008 |
Jan
(66) |
Feb
(45) |
Mar
(30) |
Apr
(50) |
May
(9) |
Jun
(18) |
Jul
(11) |
Aug
(6) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: Albert G. <Dr....@t-...> - 2006-11-25 05:18:48
|
Burton Samograd wrote: >> Albert: it would be nice if ./configure understood --with-iodbc and then >> went on to use `iodbc-config --cflags` and --libs. > > Yes, if it handled both independently then the ebuild might be a bit > nicer. Right now it's up to whether either flag is set, and which > ever one configure finds first, I guess. You guys probably know much more about ODBC than me. ;-) There's already a section for ODBC flags in configure.in, so if someone can massage that into something which is nicer/easier to use I'll be glad to add that to the next release. 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 |
From: Andrew B. <and...@ya...> - 2006-11-24 23:48:04
|
=0AAlbert Graef wrote:=0A>=0A>> =0A>> -f F =3D true if (close (open F 0 0))= =3D ();=0A>> =3D false otherwise;=0A>=0A>Note that -f is not a val= id function name in Q. What you actually define=0A>here is a rule for unary= minus applied to the constructor term f F.=0A>=0AI had recognized it as an= invalid function name already, but I rather liked the look of "-f" rather = than "_f" or (eww) "is_regular_file". And besides, the interpreter let me = get away with it!=0A=0A>> I understand that when the file does not exist, t= he "(close (open F 0 =0A>> 0))" part does not reduce, but why does "=3D ()= " part not look at =0A>> "close (open "fetch.qaz" 0 0)" and say, "nope, no= t equal"? "eq" does =0A>> the same thing. Is there something that will f= orce the equality =0A>> check to happen?=0A>=0A>eq and (=3D) are different= things in Q. The former checks for syntactic=0A>equality (which is always = defined), the latter is a comparison operator=0A>which only applies to cert= ain data types (much like (<) and (<), etc.).=0A>See Section 7.2 of the man= ual,=0A>http://q-lang.sourceforge.net/qdoc/qdoc_7.html#SEC27=0A>=0A>Of cour= se, you can add your own rules for (=3D) to extend equality to any=0A>data = types you need, but it is generally undesirable to have a very=0A>broad def= inition of (=3D) as such rules might interfere with the specific=0A>cases.= =0A=0AI (think that I) understand the =3D vs eq difference. I was surprise= d that when I tried to apply either one to an expression where the "open F = 0 0" had failed, all I got was a bigger expression.=0A=0A>So you'll have to= use eq instead. Or you could use a pattern match like so:=0A>=0A>-f F =3D = true where () =3D close (open F 0 0);=0A> =3D false otherwise;=0A=0A= Aah, that's probably the version I was looking for. So, if the evaluation = fails in a "where" clause, the containing equation fails also. Somehow I d= id not manage to learn that from my reading of the manual.=0A=0A>But I thin= k that the most convenient way to do these checks would be to=0A>use the st= at/lstat functions from clib. For instance:=0A=0A... snip a bunch...=0A=0AI= t's kind of amusing, I started out trying to write this way, but the only v= ersion of stat that I could find in the manual seemed to take a FD, which r= equired calling "open" anyhow, so since I only needed "-f" just then I sett= led on a really dumb implementation.=0A=0AThanks for the advice,=0A=0A-andr= ew=0A=0A=0A=0A=0A |
From: Tim H. <q...@st...> - 2006-11-24 21:21:54
|
John Cowan <co...@cc...> writes: [snip] > No. That's the way that Q (>=6.2, as you say) represents a tuple with one > element. The syntax used to be just "(1770)", but that meant different > things in different contexts: it meant a tuple if the parens were > redundant, or just a plain expression of the parens were necessary > because of operator priorities. > > I successfully argued that this was obnoxious, and Q was changed to use > the same syntax as Python: the final element in a tuple MAY be followed > by a comma, and MUST be if it is the only element. Naturally, the > unparser follows the same rule, inserting the final comma only in > singletons. [snip] > Lists can't be confused with simple parens, so the final comma is > never necessary and the unparser will not generate it. Ah, cool. OK, that explains things. Thanks :) ~Tim -- <http://spodzone.org.uk/> |
From: John C. <co...@cc...> - 2006-11-24 20:21:30
|
Tim Haynes scripsit: > c) A minor (probably only visual) niggle. This strikes me as having > a few too many commas for my sanity: > > | ==> import odbc > | > | ==> def H=odbc_connect "DSN=pgstraw" > | > | ==> sql H "select count(*) from gallery" () > | [("count",),(1770,)] > > I have both unixODBC and iODBC installed; on this box, Q's odbc.so is > linked against unixODBC; neither iodbctest nor isql hint at a second > column; versions of Q >=6.2incl exhibit this spare comma. No. That's the way that Q (>=6.2, as you say) represents a tuple with one element. The syntax used to be just "(1770)", but that meant different things in different contexts: it meant a tuple if the parens were redundant, or just a plain expression of the parens were necessary because of operator priorities. I successfully argued that this was obnoxious, and Q was changed to use the same syntax as Python: the final element in a tuple MAY be followed by a comma, and MUST be if it is the only element. Naturally, the unparser follows the same rule, inserting the final comma only in singletons. > I note I can type [1,2,3,] into the interpreter and get back [1,2,3] > for my trouble (so I'd expect the above resultset display to be > normalized too). Am I missing some update somewhere? Lists can't be confused with simple parens, so the final comma is never necessary and the unparser will not generate it. -- Kill Gorgun! Kill orc-folk! John Cowan No other words please Wild Men. co...@cc... Drive away bad air and darkness http://www.ccil.org/~cowan with bright iron! --Ghan-buri-Ghan http://www.ccil.org/~cowan |
From: Burton S. <kr...@gm...> - 2006-11-24 16:24:24
|
On 24 Nov 2006 15:59:26 +0000, Tim Haynes <q...@st...> wrote: > "Burton Samograd" <kr...@gm...> writes: > > [snip] > > I looked at the Q docs and found that it supported libiodbc and > > UNIXodbc; I just picked one, since I don't use the ODBC functionality > > at all. > > You could make both odbc and iodbc into optional USE flags. Done. The configuration section checks for both and if neither are enabled odbc is disabled. > Albert: it would be nice if ./configure understood --with-iodbc and then > went on to use `iodbc-config --cflags` and --libs. Yes, if it handled both independently then the ebuild might be a bit nicer. Right now it's up to whether either flag is set, and which ever one configure finds first, I guess. -- burton samograd kr...@gm... kruhft.boldlygoingnowhere.org www.myspace.com/kruhft |
From: Tim H. <q...@st...> - 2006-11-24 15:59:47
|
"Burton Samograd" <kr...@gm...> writes: [snip] > I looked at the Q docs and found that it supported libiodbc and > UNIXodbc; I just picked one, since I don't use the ODBC functionality > at all. You could make both odbc and iodbc into optional USE flags. Albert: it would be nice if ./configure understood --with-iodbc and then went on to use `iodbc-config --cflags` and --libs. > > c) A minor (probably only visual) niggle. This strikes me as having a few > > too many commas for my sanity: > > > > | ==> import odbc > > | > > | ==> def H=odbc_connect "DSN=pgstraw" > > | > > | ==> sql H "select count(*) from gallery" () > > | [("count",),(1770,)] > > > > I have both unixODBC and iODBC installed; on this box, Q's odbc.so is > > linked against unixODBC; neither iodbctest nor isql hint at a second > > column; versions of Q >=6.2incl exhibit this spare comma. I note I can type > > [1,2,3,] into the interpreter and get back [1,2,3] for my trouble (so I'd > > expect the above resultset display to be normalized too). Am I missing some > > update somewhere? > > Not sure about this problem since I don't use the ODBC at all. Maybe I > should default to using the unixODBC instead? How about I do that and you > test it and tell me if that works better for you and I'll leave it. > > I'll have the new ebuild up in a couple of minutes. Further testing has eliminated the role of driver manager here; it's just down to Q how the extra comma is coming into play. ~Tim -- <http://spodzone.org.uk/> |
From: Burton S. <kr...@gm...> - 2006-11-24 15:07:01
|
Hi Tim, Thanks for testing the ebuild. See comments below. On 24 Nov 2006 14:54:34 +0000, Tim Haynes <q...@st...> wrote: > a) isn't GMP more a requirement for Q than an optional USE thing? Correct. My mistake; I removed gmp from the configuration section, added gmp as a real dependancy. > b) interestingly, you've got the odbc option but it rebuilt libiodbc as a > dependency before building Q. Not that I'm complaining[1], of course. I looked at the Q docs and found that it supported libiodbc and UNIXodbc; I just picked one, since I don't use the ODBC functionality at all. > c) A minor (probably only visual) niggle. This strikes me as having a few > too many commas for my sanity: > > | ==> import odbc > | > | ==> def H=odbc_connect "DSN=pgstraw" > | > | ==> sql H "select count(*) from gallery" () > | [("count",),(1770,)] > > I have both unixODBC and iODBC installed; on this box, Q's odbc.so is > linked against unixODBC; neither iodbctest nor isql hint at a second > column; versions of Q >=6.2incl exhibit this spare comma. I note I can type > [1,2,3,] into the interpreter and get back [1,2,3] for my trouble (so I'd > expect the above resultset display to be normalized too). Am I missing some > update somewhere? Not sure about this problem since I don't use the ODBC at all. Maybe I should default to using the unixODBC instead? How about I do that and you test it and tell me if that works better for you and I'll leave it. I'll have the new ebuild up in a couple of minutes. -- burton samograd kr...@gm... kruhft.boldlygoingnowhere.org www.myspace.com/kruhft |
From: Tim H. <q...@st...> - 2006-11-24 14:54:51
|
"Burton Samograd" <kr...@gm...> writes: > Hi Albert, > > > Burton Samograd wrote: > > > I'm working on getting ebuild's written for Gentoo, almost as we > > > speak. I have the core interpreter installation working that handles > > > USE flags properly (AFAIK), and I'll be working on the add on modules > > > as I find time. > > I submitted my Q-7.5 ebuild to gentoo. Those who wish to try it can > find it here: > > http://bugs.gentoo.org/show_bug.cgi?id=156102 > > I tested it and it works fine on my system and since it mostly > autoconfigures itself when packages are present, the ebuild just > disables features if certain USE flags aren't set. Hopefully I managed > to get everything right with all of them. OK, I've got it installed and basically functional here on an athlon-xp box: [ebuild N ] dev-lang/q-7.5 USE="curl gdbm gmp iconv imagemagick odbc readline threads unicode xml -X -dmalloc -freetype -ggi -nls -tk -virtual/libc" 0 kB [1] I note 3 things: a) isn't GMP more a requirement for Q than an optional USE thing? b) interestingly, you've got the odbc option but it rebuilt libiodbc as a dependency before building Q. Not that I'm complaining[1], of course. c) A minor (probably only visual) niggle. This strikes me as having a few too many commas for my sanity: | ==> import odbc | | ==> def H=odbc_connect "DSN=pgstraw" | | ==> sql H "select count(*) from gallery" () | [("count",),(1770,)] I have both unixODBC and iODBC installed; on this box, Q's odbc.so is linked against unixODBC; neither iodbctest nor isql hint at a second column; versions of Q >=6.2incl exhibit this spare comma. I note I can type [1,2,3,] into the interpreter and get back [1,2,3] for my trouble (so I'd expect the above resultset display to be normalized too). Am I missing some update somewhere? [1] <cough> I'm also webmaster for iodbc </cough> ~Tim -- <http://spodzone.org.uk/> |
From: Rob H. <hub...@gm...> - 2006-11-24 14:35:08
|
Dear All, Albert has very kindly uploaded my (draft) polynomial module "Q[i][X]" version 0.2; it is available from the "Grab Bag" on the Q website at <http://q-lang.sourceforge.net/examples.html#Miscellaneous>. Some documentation is included, containing many examples. [I'm not sure how Q[i][X] should be pronounced: "quick", "quiz", "kick(s)", "keys" or "quiche" (!)] The library is limited to univariate polynomials with numerical coefficient= s. This project started out of a desire to factorise the formula for sums of powers, such as Sum (n =3D 1 .. m) : n ^ k Albert has commented on his website that "this can be seen as the beginnings of a [computer algebra system] written in Q". Ahem. There's quite a way to go yet. :-) This module is essentially numeric rather than symbolic. The coefficients of the polynomials may be any complex floating point numbers, but the module contains many routines specifically targeted at polynomials with (exact) rational complex coefficients (i.e. in Q[i]). Q[i] is the algebraic extension of the rational number field Q with i=3Dsqr= t(-1). "Q[i][X]" represents (the ring of) polynomials over (the ring) Q[i]. Similarly, the ring of "Gaussian integers" Z[i] is the extension of the ring Z of integers. Both Z and Z[i] are UFDs (unique factorisation domains); this is the basis for many of the algorithms, hence the subtitle of "Polynomial and Gaussian Module". A polynomial such as "4+3X+X^3" is currently represented by poly_with_coeffs [4,3,0,1] but I hope to have a more readable presentation in a future version. The module, so far, includes functions for: * creating polynomials in terms of the coefficients or the roots; * polynomial curve fitting; * some common polynomial arithmetic and mathematics functions (including GCD, LCM); * formal calculus (thus: square-free part); * DFT polynomials; * transformations between "difference systems" and polynomials (thus: finite sums and differences); * functions to find *all* roots in Q[i] of any polynomial over Q[i]; * functions to solve up to quartic polynomials "by radicals"; * functions for finding and using patterns in the coefficients; (for example, polynomials of a power of the indeterminate; palindromic polynomials); * functions for finding bounds of the roots; * transformations between B=E9zier representations and polynomials. I hope to extend this further. For example, I need to: * add string conversion (using Q Lex Yacc); * add some B=E9zier functions; * add functions for summarising "features" (local extrema; points of inflection); * add root approximation functions. I hope to include these in the next release. Possibly, *much* later, I might * extend support to polynomials over a general ring/field (for example, square matrices, symbols) * add some support for rational functions Please report any bugs or errors in the module or in its documentation to me (either directly or via this mailing list) rather than Albert. Questions concerning the use of Q[i][X] should probably come (to me) via the mailing list. Thanks. Enjoy. Rob. |
From: Burton S. <kr...@gm...> - 2006-11-24 10:15:44
|
Hi Albert, > Burton Samograd wrote: > > I'm working on getting ebuild's written for Gentoo, almost as we > > speak. I have the core interpreter installation working that handles > > USE flags properly (AFAIK), and I'll be working on the add on modules > > as I find time. I submitted my Q-7.5 ebuild to gentoo. Those who wish to try it can find it here: http://bugs.gentoo.org/show_bug.cgi?id=156102 I tested it and it works fine on my system and since it mostly autoconfigures itself when packages are present, the ebuild just disables features if certain USE flags aren't set. Hopefully I managed to get everything right with all of them. > that's very good news! Thanks a lot for your work on this. Please let me > know if you run into any portability quirks so that I can add the > necessary patches to the next release. No problems at all with compiling on my system. -- burton samograd kr...@gm... kruhft.boldlygoingnowhere.org www.myspace.com/kruhft |
From: Albert G. <Dr....@t-...> - 2006-11-24 08:20:15
|
Andrew Berg wrote: > ...I'd sure appreciate a bit of help. > > I'm trying to write some file test functions, like the -f and -d > functions in perl or shell scripts. Here is what I have so far: > > -f F = true if (close (open F 0 0)) = (); > = false otherwise; Note that -f is not a valid function name in Q. What you actually define here is a rule for unary minus applied to the constructor term f F. > I understand that when the file does not exist, the "(close (open F 0 > 0))" part does not reduce, but why does "= ()" part not look at > "close (open "fetch.qaz" 0 0)" and say, "nope, not equal"? "eq" does > the same thing. Is there something that will force the equality > check to happen? eq and (=) are different things in Q. The former checks for syntactic equality (which is always defined), the latter is a comparison operator which only applies to certain data types (much like (<) and (<), etc.). See Section 7.2 of the manual, http://q-lang.sourceforge.net/qdoc/qdoc_7.html#SEC27 Of course, you can add your own rules for (=) to extend equality to any data types you need, but it is generally undesirable to have a very broad definition of (=) as such rules might interfere with the specific cases. So you'll have to use eq instead. Or you could use a pattern match like so: -f F = true where () = close (open F 0 0); = false otherwise; But I think that the most convenient way to do these checks would be to use the stat/lstat functions from clib. For instance: ftype NAME = MODE and S_IFMT where MODE:Int = st_mode (stat NAME); = -1 otherwise; This will give you the type of the file if it exists (which can then be tested against the corresponding constants in clib.q to implement the specific checks that you need), and -1 otherwise. ==> hex ==> (S_IFBLK, S_IFCHR, S_IFIFO, S_IFREG, S_IFDIR, S_IFLNK, S_IFSOCK) (0x6000,0x2000,0x1000,0x8000,0x4000,0xa000,0xc000) ==> ftype "doesnt-exist" -0x1 ==> ftype "test.q" // a regular file 0x8000 ==> ftype "src" // a directory 0x4000 Greetings, 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 |
From: Albert G. <Dr....@t-...> - 2006-11-24 07:35:34
|
Burton Samograd wrote: > I'm working on getting ebuild's written for Gentoo, almost as we > speak. I have the core interpreter installation working that handles > USE flags properly (AFAIK), and I'll be working on the add on modules > as I find time. Hi Burton, that's very good news! Thanks a lot for your work on this. Please let me know if you run into any portability quirks so that I can add the necessary patches to the next release. Now, is there anyone out there who might be willing to maintain a Debian package? Kari Pahula was working on this quite a while ago, but I can't find his package on mentor.debian.net any more. 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 |
From: Andrew B. <and...@ya...> - 2006-11-24 04:01:42
|
...I'd sure appreciate a bit of help. I'm trying to write some file test functions, like the -f and -d functions in perl or shell scripts. Here is what I have so far: -f F = true if (close (open F 0 0)) = (); = false otherwise; Which when run gives me: ==> -f "fetch.q" true ==> -f "fetch.qaz" ! Error in conditional 0> fetch.q, line 11: -f "fetch.qaz" ==> true if close (open "fetch.qaz" 0 0)=() As I understand this, it meains that the "if" got something other than true/false. It seems like I could write another function (or maybe use a lambda) to include a "catch" clause, but this seems like such a simple thing, so I have the feeling that I am missing something fundamental. I understand that when the file does not exist, the "(close (open F 0 0))" part does not reduce, but why does "= ()" part not look at "close (open "fetch.qaz" 0 0)" and say, "nope, not equal"? "eq" does the same thing. Is there something that will force the equality check to happen? -andrew |
From: Burton S. <kr...@gm...> - 2006-11-24 02:15:18
|
I'm working on getting ebuild's written for Gentoo, almost as we speak. I have the core interpreter installation working that handles USE flags properly (AFAIK), and I'll be working on the add on modules as I find time. On 11/23/06, Albert Graef <Dr....@t-...> wrote: > Hi all, > > The RedHat users among you might be interested in this. I just noticed > that Q is now in the Fedore extras tree, see > http://fedoraproject.org/extras/6/i386/repodata/repoview/q-0-7.5-1.fc6.html > > Nice to see that some distributions are finally picking it up. Makes my > task a little easier. ;-) > > Cheers, > Albert > > P.S.: If anyone here has tried the FC Q packages, I'd be interested to > hear whether they are actually working, what stuff is missing, etc. > > -- > 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 > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > q-lang-users mailing list > q-l...@li... > https://lists.sourceforge.net/lists/listinfo/q-lang-users > -- burton samograd kr...@gm... kruhft.boldlygoingnowhere.org www.myspace.com/kruhft |
From: Albert G. <Dr....@t-...> - 2006-11-23 23:26:51
|
Hi all, The RedHat users among you might be interested in this. I just noticed that Q is now in the Fedore extras tree, see http://fedoraproject.org/extras/6/i386/repodata/repoview/q-0-7.5-1.fc6.html Nice to see that some distributions are finally picking it up. Makes my task a little easier. ;-) Cheers, Albert P.S.: If anyone here has tried the FC Q packages, I'd be interested to hear whether they are actually working, what stuff is missing, etc. -- 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 |
From: Albert G. <Dr....@t-...> - 2006-11-23 21:16:31
|
Eddie Rucker wrote: > Addendum (add this to the readability/performance question): I also just > discovered I don't need variables (although I saw something like this > somewhere in the docs): > > addSurvey = zipwith (zipwith (+)); > addSurveyId = map (mklist 0 . (#)); Yes, that's what Haskellers call the "pointless style" (pun intended). In Haskell there's no semantic difference between the two styles. In Q there is a slight difference in operational semantics, namely that with a definition like "foo = bar" the expression "foo" is reduced immediately, whereas with "foo X = bar X" you have to supply an argument to foo before a reduction happens. 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 |
From: Albert G. <Dr....@t-...> - 2006-11-23 21:10:08
|
Eddie Rucker wrote: > I've go two lines in a program that computes stats on a file of surveys: > > addSurvey X Y = zipwith (zipwith (+)) X Y; > addSurveyId A = map Id A where Id = (mklist 0) . (#); > > where X and Y are two lists with a 1 in the position of the student > response, like [0,0,1,0,0], and each survey is a list of these lists. > > My question is: > Does the "where" in addSurveyId compute "(mklist 0) . (#)" once and use > the new function throughout the map operation? Or does map just put > "(mklist 0) .(#)" in front of each element in the list and then reduce? It doesn't actually matter because: - The arguments to map are evaluated before map does its thing, so assigning the function to a local variable is just a convenience but doesn't change the course of the computation (unless, of course, you'd refer to the same computed function twice, in which case a local variable definition helps to avoid its recalculation). - In this special case mklist 0 . (#) is already a normal form anyway, so it just evaluates to itself (as you can readily verify by entering the expression directly in the interpreter). In general you can think of (.) as being defined by (F.G) X = F (G X), so an expression involving (.) is reduced no earlier than the argument to the composed function is supplied. Note that evaluation is a bit different in Q than in ML or Haskell or any other modern-style FPL you might know, where equations are just syntactic sugar for lambdas and the lambda calculus is the basic machinery of computation. In such languages a closure will be created for each function expression, so a function expression will evaluate to something which is different from the expression itself. In Q it's all just term rewriting, so if a (function) expression like mklist 0 . (#) just stands for itself then that's fine with the interpreter. The interpreter doesn't care whether the expression denotes a function, in fact it doesn't even know what a function is! All it does is rewriting expressions according to the equations until it reaches a normal form. > Second question: > Which is better, readability and/or performance wise? > > "addSurveyId A = map (\X. mklist 0 (#X) A;" > > or > > "addSurveyId A = map ZeroVec A where ZeroVec = (mklist 0) . (#);" > > or > > "addSurveyId A = map (mklist 0 .(#)) A;" Readability-wise, I'd prefer the latter, but that's just personal preference. Performance-wise, there shouldn't be a big difference, although the first alternative might be a tad slower because it involves an extra builtin (lambda). In fact on my system I get: ==> #addSurveyId1 (mklist [0,0,1,0,0] 100000); stats 100000 0.94 secs, 400005 reductions, 700010 cells ==> #addSurveyId2 (mklist [0,0,1,0,0] 100000); stats 100000 0.89 secs, 400004 reductions, 700005 cells ==> #addSurveyId3 (mklist [0,0,1,0,0] 100000); stats 100000 0.91 secs, 400004 reductions, 700005 cells 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 |
From: Eddie R. <ed...@bm...> - 2006-11-10 17:22:26
|
Eddie Rucker, Addendum (add this to the readability/performance question): I also just discovered I don't need variables (although I saw something like this somewhere in the docs): addSurvey = zipwith (zipwith (+)); addSurveyId = map (mklist 0 . (#)); > I've go two lines in a program that computes stats on a file of surveys: > > addSurvey X Y = zipwith (zipwith (+)) X Y; > addSurveyId A = map Id A where Id = (mklist 0) . (#); > > where X and Y are two lists with a 1 in the position of the student > response, like [0,0,1,0,0], and each survey is a list of these lists. > > My question is: > Does the "where" in addSurveyId compute "(mklist 0) . (#)" once and use > the new function throughout the map operation? Or does map just put > "(mklist 0) .(#)" in front of each element in the list and then reduce? > > Second question: > Which is better, readability and/or performance wise? > > "addSurveyId A = map (\X. mklist 0 (#X) A;" > > or > > "addSurveyId A = map ZeroVec A where ZeroVec = (mklist 0) . (#);" > > or > > "addSurveyId A = map (mklist 0 .(#)) A;" > > Eddie > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > q-lang-users mailing list > q-l...@li... > https://lists.sourceforge.net/lists/listinfo/q-lang-users > |
From: Eddie R. <ed...@bm...> - 2006-11-10 17:16:41
|
I've go two lines in a program that computes stats on a file of surveys: addSurvey X Y = zipwith (zipwith (+)) X Y; addSurveyId A = map Id A where Id = (mklist 0) . (#); where X and Y are two lists with a 1 in the position of the student response, like [0,0,1,0,0], and each survey is a list of these lists. My question is: Does the "where" in addSurveyId compute "(mklist 0) . (#)" once and use the new function throughout the map operation? Or does map just put "(mklist 0) .(#)" in front of each element in the list and then reduce? Second question: Which is better, readability and/or performance wise? "addSurveyId A = map (\X. mklist 0 (#X) A;" or "addSurveyId A = map ZeroVec A where ZeroVec = (mklist 0) . (#);" or "addSurveyId A = map (mklist 0 .(#)) A;" Eddie |
From: Albert G. <Dr....@t-...> - 2006-11-03 07:45:01
|
Keith Trenton wrote: > Assuming that you will be there: good luck with your presentation! =) Thanks. :) 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 |
From: Albert G. <Dr....@t-...> - 2006-11-03 07:43:31
|
Keith Trenton wrote: > - sieve {X|Xs} = {X|var Y : sieve {Y:Y in Xs,Y mod X<>0}}; > > [1] one advantage wrt. in-ining "var Y : " : only one (1) line of code is required (see above); The other advantage is that the scope of the variable(s) would be restricted just to a single expression instead of the entire rule. > [2] one (possible) disadvantage wrt. in-ining "var Y : " : are we overloading the colon <:> in an ambiguous way? I don't think so. The "var" should disambiguate it. > [a] sieve {X|Xs} = {X|local Y : sieve {Y:Y in Xs,Y mod X<>0}}; We already have the "var" keyword so why not use it? > [b] sieve {X|Xs} = {X|var Y in sieve {Y:Y in Xs,Y mod X<>0}}; "in" doesn't work, it can't be a predefined keyword, because it's declared as a user-defined operator in the standard library. That's why I picked the colon instead. > [d] sieve {X|Xs} = {X|Y| sieve {Y:Y in Xs,Y mod X<>0}}; This looks nice but introduces syntactic ambiguities because | is also used in the list/stream syntax. E.g., consider {X|bla X}. Is that a stream with head X and tail bla X or a single-element stream with a var declaration in it? 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 |
From: wilbur p. <kur...@sv...> - 2006-11-03 05:26:46
|
Real time trades. Bottom Feeder Alert Brave man! cried Rob, laughingly; you've avoided the = pangs of starvation for a time, anyhow, so I can leave you with a clear c= onscience. Aggressive traders will want to pay close attention to, Remington Venture= s Inc. Mortals who stand upon the earth and look up at the sky cannot oft= en distinguish these forms, but our friends were now so near to the cloud= s that they observed the dainty fairies very clearly. RMVN the. 0.07 last trade! Without more ado, he turned the indicator of the traveli= ng machine and mounted into the air, leaving the Turk sitting upon the ro= cks and staring after him in comical bewilderment. Remington Ventures Flips the 1.5 TriIIion DoIIar Daily Currency Exchange = Market with it's new technology. 15. Go to the RMVN website and read up on this amazing new technology. A Bat= tle with Monsters Our young adventurer never experienced a more grateful = feeling of relief and security than when he found himself once more high = in the air, alone, and in undisputed possession of the electrical devices= bestowed upon him by the Demon. It not only analizes the 1.5 TriIIion a day FX Market but is able to show= trends and tell you what the next big mover will be. How amazing is that= ?!! Are they real? asked Zeb, in an awed voice. RMVN is at a low low price. machine. ---The last time RNVN took a run the price sky rocketed all the way to 1.= 90--- The dangers he had passed through since landing at the city of the = desert and the desperate chance that alone had permitted him to regain th= e traveling machine made him shudder at the bare recollection and rendere= d him more sober and thoughtful than usual. Bottom feeders mean low, low price. Buy low sell high! Remember hearing t= hat? We who stick closely to the earth's surface can scarcely realize how= Rob could travel through the air at such dizzy heights without any fear = or concern whatsoever, But he had come to consider the air a veritable re= fuge. Experience had given him implicit confidence in the powers of the e= lectrical instrument whose unseen forces carried him so swiftly and surel= y, and while the tiny, watch-like machine was clasped to his wrist he fel= t himself to be absolutely safe. Information in this report may contain forward 1ook ing statements within= the meaning of sec tion , 27 a of the Securitiesact of l933 and Section = 2lB of the SEC Act of l934, statements that involve discussions of future= events. Of course, replied Dorothy, softly. Don't rely on them. Past perf 0rmance isnt indicitive of future results. = We have not received any payment for this advertisementfor rmvn but we ar= e in talks and expect to receive a ca 5h payment from a thirdparty, not a= n officer or director or affi Iiate. PennySt0 cks are high ris k. They a= re the Cloud Fairies. If you are not a sav vy in vest or we suggest you sit back and justwatch.= This report shall not be construed as any kind of recommendation ln vest= ment advice orsolicitation.It is a watch only, always Call yourbroker or = ln vestment advisor first. Having slipped away from the Turk and attained= a fair altitude, he set the indicator at zero and paused long enough to = consult his map and decide what direction it was best for him to take. |
From: Keith T. <kaz...@ea...> - 2006-11-03 03:06:00
|
--- Albert Graef <Dr....@t-...> wrote: - ...and just in time for ICMC 2006... Assuming that you will be there: good luck with your presentation! =) Cheers, Keith |
From: Keith T. <kaz...@ea...> - 2006-11-03 03:04:03
|
If I may offer my two cents ... --- Albert Graef <Dr....@t-...> wrote: --- var Y in --- sieve {X|Xs} = {X|sieve {Y:Y in Xs,Y mod X<>0}}; [1] one advantage wrt. writing "var Y in" : definitions remain free of clutter; [2] one disadvantage wrt. writing "var Y in" : it takes two (2) lines of code to do the work of one. Paul Graham once declared that "succinctness is power" [ http://www.paulgraham.com/power.html ]; and personally, I prefer writing one slightly longer line of code over writing two lines of code. --- Albert Graef <Dr....@t-...> wrote: - sieve {X|Xs} = {X|var Y : sieve {Y:Y in Xs,Y mod X<>0}}; [1] one advantage wrt. in-ining "var Y : " : only one (1) line of code is required (see above); [2] one (possible) disadvantage wrt. in-ining "var Y : " : are we overloading the colon <:> in an ambiguous way? Obviously, I do not know; what about it, Albert? Other than this question, it looks nice and fairly "Q-ish". Alternatives : [a] sieve {X|Xs} = {X|local Y : sieve {Y:Y in Xs,Y mod X<>0}}; [b] sieve {X|Xs} = {X|var Y in sieve {Y:Y in Xs,Y mod X<>0}}; [c] sieve {X|Xs} = {X|local Y in sieve {Y:Y in Xs,Y mod X<>0}}; [d] sieve {X|Xs} = {X|Y| sieve {Y:Y in Xs,Y mod X<>0}}; Wait a minute... I think [d] is a "ringer". It looks like Smalltalk to me! =) Cheers, Keith |
From: Albert G. <Dr....@t-...> - 2006-11-02 23:27:55
|
Rob Hubbard wrote: > I would like to use inline "var"s. Unfortunately, that might then hide > another undeclared symbol elsewhere in my script. Right. :( Those inline var's should really be confined to the lexical scope of a single definition. Why haven't I thought about this before?? > var Y in > sieve {X|Xs} = {X|sieve {Y:Y in Xs,Y mod X<>0}}; Not a bad idea. Another possible approach would be to attach an inline var to an expression, as in: sieve {X|Xs} = {X|var Y : sieve {Y:Y in Xs,Y mod X<>0}}; The scope of the var declaration would then be limited to the expression after the ':'. Eddie's example could then be written as: outliers X = filter (var X : \X . (X < LF) or (X > RF)) X ...; That would be much more useful than the inline var declarations we have now. Opinions? Anyone against this change? 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 |