q-lang-users Mailing List for Q - Equational Programming Language (Page 35)
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-08-19 05:42:45
|
John Cowan wrote: > I did a "make uninstall" from the q-7.2 directory, then removed q-7.3 > and remade it from the untouched tarball. Same error. As promised, I checked the native Windows port with the latest cvs and it builds and runs fine. I've also reviewed the (very few) changes between 7.2 and the latest cvs and I don't see anything in there which could possibly break the module loader; in fact a 7.2 libq should still work fine since there were no changes in it. Could you please try and recompile the most recent version that you had working on your system (7.2 I guess) and see whether it still builds ok? 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: dx <dx...@ac...> - 2006-08-15 19:41:14
|
Hi, I am attaching the source code that I found. dex Albert Graef wrote: > dx wrote: >> By the way, is there anyone knows Wm Leler's Bertrand(augmented term rewriting), >> I read the book a long time ago, I am just wondering how close it is to Q. > > Sounds interesting. Interesting guy, too. I googled around some but most > links to actual information and the sources seem to be dead. Does anyone > have the sources for Bertrand lying around somewhere? I'd like to take a > look, too. > > Albert > |
From: Albert G. <Dr....@t-...> - 2006-08-15 18:08:44
|
Anthony wrote: > What I'd like to do is just write a small Q program > that parses a line of input according to the rules of > Mathematica. No need to evaluate the functions...just > want to build a syntax checker at first. Concerning the parser for the input language, that should be a nice opportunity to try Q Yacc+Lex. (The lexical analyzers generated by Q Lex are still a bit slow right now, but I'm working on this.) But, as Rob already explained, building a CAS, even a basic one, is not as simple as it might look. > Or maybe I am dreaming... Well, I started dreaming about an easy-to-use FP language one day... :) 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: Albert G. <Dr....@t-...> - 2006-08-15 17:59:27
|
dx wrote: > By the way, is there anyone knows Wm Leler's Bertrand(augmented term rewriting), > I read the book a long time ago, I am just wondering how close it is to Q. Sounds interesting. Interesting guy, too. I googled around some but most links to actual information and the sources seem to be dead. Does anyone have the sources for Bertrand lying around somewhere? I'd like to take a look, too. 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: dx <dx...@ac...> - 2006-08-15 14:02:46
|
Hi, If you want CAS, you can try Maxima or Axiom. By the way, is there anyone knows Wm Leler's Bertrand(augmented term rewriting), I read the book a long time ago, I am just wondering how close it is to Q. Thanks, dex Rob Hubbard wrote: > Hello Anthony, > > I too first became interested in 'Q' because of mathematics. I am > fairly new to Q too. > > Q is not, in my view, a typical functional language. If you're > interested in learning functional languages, you should also take a > look at some others. It would probably be instructive to try Standard > ML <http://www.smlnj.org/>. There are many other interesting > functional languages. However, I think you will really enjoy using Q. > It's one of the languages that I most enjoy using. > > Beware that Q may not always behave quite as you expect at first. For > example, if you enter the simple program consisting of just the > rewrite rule: > X+X = 2*X; > and the giving Q some expressions to reduce: > ==> A+A+B > 2*A+B > ==> A+B+B > A+B+B > the final response from Q may not be what you expect. > > A+B+B, which is (A+B)+B due to the left-associativity of (+), was not > reduced, as this does not match the given rule. > With the additional rule > Y+X+X = Y+2*X; > you will now get the responses from the Q system > ==> A+B+B > A+2*B > ==> A+A+B+B+C+C+D+D > 2*A+2*B+2*C+2*D > > To quote Albert Graef's informative reply to one of my questions: > 'Yes, it's surprisingly hard to do apparently basic stuff like this, > because it involves "rewriting modulo AC" (AC = > associativity/commutativity). The conventional way to deal with this > is to transform the original terms into a "sum of products" normal > form and represent that as a list which is lexicographically ordered > according to the involved symbols. It's not really that hard to do but > it indeed involves additional rules on a kind of meta-level, so there > is no straightforward solution with just a few equations.' > > I was at first disappointed with Q not being the simple computer > algebra system I hoped it would be. But then that's not what it's > intended to be. Once you get used to it, you find that Q does seem to > do the "right thing". Those involved with developing Q take great care > to keep Q a sensible and consistent language. (See for example the > helpful reply from John Cowan in a discussion > <http://sourceforge.net/mailarchive/message.php?msg_id=19294969> of > type tests, in the lead up to the release of Q7.2) > > Not many languages that I know are so well thought out, but I think > that Q is. And Q has fairly comprehensive libraries, together with > comprehensive programming tools, such as the debugger. > > When I want to do some maths, I now usually reach for Q. But I tend to > write code for the specific type of mathematical object I'm currently > interested in. I imagine that to write a fairly comprehensive symbolic > computer algebra system would be a job of comparable complexity in any > language, Q, C++, ML, Python, or any other "general purpose" language. > > By the way, if anyone does know of a good free / open source symbolic > computer algebra system or programming language, please let me know. > Mathematica is unbelievably expensive, and I don't need anything that > powerful or comprehensive. > > I hope these comments (and opinions) are helpful, > Rob. > > On 15/08/06, Anthony <ad...@ke...> wrote: >> Just a general question...Q is my first experience >> with a functional language. What would it take to >> write a Mathematica clone in Q? >> >> I don't mean a full-Mathematica clone, but something >> that would emulate the kernel mode, circa 1988--an >> unlimited integer, numeric, graphical, and symbolic >> program with an easy syntax. >> >> For example x + 8 will generate internally a >> Plus[x,8] production, and 1+x^2+(y+z)^2 generates >> >> Plus[1, Power[x,2], Power[Plus[y,z],2]] >> >> What I'd like to do is just write a small Q program >> that parses a line of input according to the rules of >> Mathematica. No need to evaluate the functions...just >> want to build a syntax checker at first. >> >> Or maybe I am dreaming... > > ------------------------------------------------------------------------- > 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: Kristof B. <kr...@vl...> - 2006-08-15 10:42:36
|
"Rob Hubbard" <hub...@gm...> writes: > <snip> > > By the way, if anyone does know of a good free / open source symbolic > computer algebra system or programming language, please let me know. > Mathematica is unbelievably expensive, and I don't need anything that > powerful or comprehensive. > There are several. Maxima and yacal come to my mind. The wikipedia article at http://en.wikipedia.org/wiki/Computer_algebra_system has a list of propietary and open source algebra systems. I can't really say if they are very good, since I haven't used them seriously, but i.e. when I took a glance at maxima, it seemed quite powerful. Kristof |
From: Rob H. <hub...@gm...> - 2006-08-15 09:41:44
|
Hello Anthony, I too first became interested in 'Q' because of mathematics. I am fairly new to Q too. Q is not, in my view, a typical functional language. If you're interested in learning functional languages, you should also take a look at some others. It would probably be instructive to try Standard ML <http://www.smlnj.org/>. There are many other interesting functional languages. However, I think you will really enjoy using Q. It's one of the languages that I most enjoy using. Beware that Q may not always behave quite as you expect at first. For example, if you enter the simple program consisting of just the rewrite rule: X+X = 2*X; and the giving Q some expressions to reduce: ==> A+A+B 2*A+B ==> A+B+B A+B+B the final response from Q may not be what you expect. A+B+B, which is (A+B)+B due to the left-associativity of (+), was not reduced, as this does not match the given rule. With the additional rule Y+X+X = Y+2*X; you will now get the responses from the Q system ==> A+B+B A+2*B ==> A+A+B+B+C+C+D+D 2*A+2*B+2*C+2*D To quote Albert Graef's informative reply to one of my questions: 'Yes, it's surprisingly hard to do apparently basic stuff like this, because it involves "rewriting modulo AC" (AC = associativity/commutativity). The conventional way to deal with this is to transform the original terms into a "sum of products" normal form and represent that as a list which is lexicographically ordered according to the involved symbols. It's not really that hard to do but it indeed involves additional rules on a kind of meta-level, so there is no straightforward solution with just a few equations.' I was at first disappointed with Q not being the simple computer algebra system I hoped it would be. But then that's not what it's intended to be. Once you get used to it, you find that Q does seem to do the "right thing". Those involved with developing Q take great care to keep Q a sensible and consistent language. (See for example the helpful reply from John Cowan in a discussion <http://sourceforge.net/mailarchive/message.php?msg_id=19294969> of type tests, in the lead up to the release of Q7.2) Not many languages that I know are so well thought out, but I think that Q is. And Q has fairly comprehensive libraries, together with comprehensive programming tools, such as the debugger. When I want to do some maths, I now usually reach for Q. But I tend to write code for the specific type of mathematical object I'm currently interested in. I imagine that to write a fairly comprehensive symbolic computer algebra system would be a job of comparable complexity in any language, Q, C++, ML, Python, or any other "general purpose" language. By the way, if anyone does know of a good free / open source symbolic computer algebra system or programming language, please let me know. Mathematica is unbelievably expensive, and I don't need anything that powerful or comprehensive. I hope these comments (and opinions) are helpful, Rob. On 15/08/06, Anthony <ad...@ke...> wrote: > > Just a general question...Q is my first experience > with a functional language. What would it take to > write a Mathematica clone in Q? > > I don't mean a full-Mathematica clone, but something > that would emulate the kernel mode, circa 1988--an > unlimited integer, numeric, graphical, and symbolic > program with an easy syntax. > > For example x + 8 will generate internally a > Plus[x,8] production, and 1+x^2+(y+z)^2 generates > > Plus[1, Power[x,2], Power[Plus[y,z],2]] > > What I'd like to do is just write a small Q program > that parses a line of input according to the rules of > Mathematica. No need to evaluate the functions...just > want to build a syntax checker at first. > > Or maybe I am dreaming... |
From: Anthony <ad...@ke...> - 2006-08-15 08:21:58
|
Just a general question...Q is my first experience with a functional language. What would it take to write a Mathematica clone in Q? I don't mean a full-Mathematica clone, but something that would emulate the kernel mode, circa 1988--an unlimited integer, numeric, graphical, and symbolic program with an easy syntax. For example x + 8 will generate internally a Plus[x,8] production, and 1+x^2+(y+z)^2 generates Plus[1, Power[x,2], Power[Plus[y,z],2]] What I'd like to do is just write a small Q program that parses a line of input according to the rules of Mathematica. No need to evaluate the functions...just want to build a syntax checker at first. Or maybe I am dreaming... |
From: Albert G. <Dr....@t-...> - 2006-08-15 07:06:33
|
John Cowan wrote: > I did a "make uninstall" from the q-7.2 directory, then removed q-7.3 > and remade it from the untouched tarball. Same error. Sorry, I have no idea right now. Neither libq nor clib has changed, and everything builds and runs fine under Linux, so I guess it must be some Windows-specific quirk. :( I'll try a Windows build asap to see whether I can reproduce this. -- 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: John C. <co...@cc...> - 2006-08-14 20:44:27
|
Albert Graef scripsit: > Hi John, > > that's strange because there weren't any changes in clib.q/c between 7.2 > and 7.3 RC2. Are you sure that ../modules/clib built properly? Is there > maybe an old version of libq lying around somewhere that might be picked > up by the loader instead of the one in ../libq? I did a "make uninstall" from the q-7.2 directory, then removed q-7.3 and remade it from the untouched tarball. Same error. -- After fixing the Y2K bug in an application: John Cowan WELCOME TO <censored> co...@cc... DATE: MONDAK, JANUARK 1, 1900 http://www.ccil.org/~cowan |
From: Albert G. <Dr....@t-...> - 2006-08-14 19:22:17
|
Hi John, that's strange because there weren't any changes in clib.q/c between 7.2 and 7.3 RC2. Are you sure that ../modules/clib built properly? Is there maybe an old version of libq lying around somewhere that might be picked up by the loader instead of the one in ../libq? John Cowan wrote: > Building on Cygwin crashes with: > > make[2]: Entering directory `/opt/q-7.3/src' > PATH=".:/home/JCowan/bin:/usr/local/ant/bin:/usr/java/j2sdk1.4.2_10/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/Perl/bin/:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/ATI Technologies/ATI Control Panel:/cygdrive/c/Program Files/MySQL/MySQL Server 5.0/bin:/cygdrive/c/Program Files/QuickTime/QTSystem/:/cygdrive/c/Program Files/Microsoft SQL Server/90/Tools/binn/:/cygdrive/c/Program Files/Mondrian/bin:/bin:/usr/lib/lapack:/usr/local/bin/darcs" QPATH="../stdlib:../modules/clib:../modules/clib" ./q ./qcwrap.q ./qcwrap.q > /opt/q-7.3/src/../modules/clib/clib.q: error loading module > Warning: 267 unresolved external symbols > ! File clib.q, line 297: Value mismatch in definition > make[2]: *** [qcwrap.c] Error 2 -- 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: John C. <co...@cc...> - 2006-08-14 17:48:11
|
Albert Graef scripsit: > As usual, feedback is appreciated. Building on Cygwin crashes with: make[2]: Entering directory `/opt/q-7.3/src' PATH=".:/home/JCowan/bin:/usr/local/ant/bin:/usr/java/j2sdk1.4.2_10/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/Perl/bin/:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/ATI Technologies/ATI Control Panel:/cygdrive/c/Program Files/MySQL/MySQL Server 5.0/bin:/cygdrive/c/Program Files/QuickTime/QTSystem/:/cygdrive/c/Program Files/Microsoft SQL Server/90/Tools/binn/:/cygdrive/c/Program Files/Mondrian/bin:/bin:/usr/lib/lapack:/usr/local/bin/darcs" QPATH="../stdlib:../modules/clib:../modules/clib" ./q ./qcwrap.q ./qcwrap.q /opt/q-7.3/src/../modules/clib/clib.q: error loading module Warning: 267 unresolved external symbols ! File clib.q, line 297: Value mismatch in definition make[2]: *** [qcwrap.c] Error 2 -- But that, he realized, was a foolish John Cowan thought; as no one knew better than he co...@cc... that the Wall had no other side. http://www.ccil.org/~cowan --Arthur C. Clarke, "The Wall of Darkness" |
From: Kristof B. <kr...@vl...> - 2006-08-14 16:21:55
|
Albert Graef <Dr....@t-...> writes: > Kristof Bastiaensen wrote: >> If I get a working version of my html library, I'll let it know, and >> post it somewhere! > > That would be nice. I could also upload it to q-lang.sf.net and make it > available in the "grab bag" if you want. > Yes, that would be nice, once I finish it. At the moment it is still quite modest though, I'll need to add a bit of functionality, and check that it doesn't have bugs... Regards, Kristof |
From: Albert G. <Dr....@t-...> - 2006-08-14 14:51:31
|
Kristof Bastiaensen wrote: > If I get a working version of my html library, I'll let it know, and > post it somewhere! That would be nice. I could also upload it to q-lang.sf.net and make it available in the "grab bag" if you want. 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: Kristof B. <kr...@vl...> - 2006-08-14 13:19:41
|
> ---- snip ------- >> However I came across the following strange behaviour. In the >> equation: >> >> test '(A B) = ('A, 'B); >> >> I would expect test '(a (2 + 3)) to evaluate to ('a, '(2 + 3)), >> however it evaluates to ('a, '5). Is this the defined behaviour? > > Yes, it is, but only since Q 7.1. The general rule is that, while > special arguments of a function will never be evaluated, deferred > subterms inside a _non-special_ arg are evaluated automatically when > they are needed in the pattern matching process. This is a > convenience so that non-special functions can assume matched > subterms to be in (weak) normal form, which is important to make > functions operating on lazy data structures such as streams do the > right thing. Yes, it makes more sense now! >> Also, when using the Q interpreter to write scripts, it always >> prints the last object to stdout. Is there an option to turn it >> off? If I want to write a script that outputs some text, I >> wouldn't want the output to be clobbered with an object. > > Explicitly exiting from the program with `exit 0' probably does what > you want. Thanks, that does the trick. If I get a working version of my html library, I'll let it know, and post it somewhere! Regards, Kristof |
From: Albert G. <Dr....@t-...> - 2006-08-14 12:40:55
|
Hi, I've just uploaded the first candidate for the upcoming Q 7.3 release (source tarball and rpms), featuring the change in the semantics of const discussed on the list as well as several bugfixes. You can find it here: http://sourceforge.net/project/showfiles.php?group_id=96881&package_id=188958&release_id=439339 Also available at the same location is my first version of Q Yacc and Lex (100% Q, no C Yacc/Lex is required to run these). Note that Q Yacc/Lex needs Q 7.3. I still need to work on the performance of the yylex function, but if you don't care too much about speed then the current snapshot already works very nicely. Preliminary documentation is in the README file and the obligatory desktop calculator example is also included. Enjoy! :) As usual, feedback is appreciated. 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: Roy J. <Haw...@my...> - 2006-08-13 17:42:35
|
<HTML><HEAD> </HEAD> <BODY bgColor=#ffffff> <DIV> <p><strong>Inve st alerts for lists.sourceforge.net users!!!!</strong></p> <p>Here at World Stock Report we work on what we here from the street.</p> <p>This is your chance to get in while it is still low.</p> <DIV><font face="Tahoma"><SPAN style="FONT-SIZE: 2px; COLOR: #000000; BACKGROUND-COLOR: transparent">wind was in our favor. "I got into the boat and we rowed to a little</span></font></DIV> <DIV> <p>Trade Date: Monday, August 14, 2006<br> Company: CHINA WORLD TRADE CORP.<br> <strong>Symbol: CWTD</strong><br> Price: $0.80<br> 7 Days Tradi ng Target: $2.50<br> 30 Day T rading Target: $3.50<br> <strong>Rating: Strong Buy</strong></p> <font face="Tahoma"><SPAN style="FONT-SIZE: 2px; COLOR: #000000; BACKGROUND-COLOR: transparent">about himself?" She tossed her hair back. Serious and practical. IShe had abandoned all pretense, she was hot, passionate, she kissedknow this is a trick, something my sister must have helped to play.</span></font></DIV> <p> We Love this company and at anytime they<b> can put out major news and the price can triple.<br> New n</b>ews expect<u>ed this comming</u> week.<br> The chart on CWTD is a thing of beauty as it shows what we mentioned earlier slow and steady upward movement.<br> </p> <DIV><br> </DIV> </DIV> <DIV><font face="Tahoma"><SPAN style="FONT-SIZE: 2px; COLOR: #000000; BACKGROUND-COLOR: transparent">anaglyphdirectrixalexandriabanisterandeanbrooklyndalzellbryanancestorcayleychardclementavertbobbiebeautify</span></font></DIV> <p>Good luck!! lists.sourceforge.net team!!.</p> <p>Sun, 13 Aug 2006 10:41:34 -0700</p> <p> </p> <p>She laughed. "But it is horse trading. Really, isn't it? Even betweendark night, no moon, but the stars diffused a very faint luminescence</p> </BODY></HTML> |
From: Albert G. <Dr....@t-...> - 2006-08-04 07:50:17
|
Hi Kristof, and welcome to the list! > However I came across the following strange behaviour. In the > equation: > > test '(A B) = ('A, 'B); > > I would expect test '(a (2 + 3)) to evaluate to ('a, '(2 + 3)), Just make `test' a special form, then you get the behaviour that you want, see below. > however it evaluates to ('a, '5). Is this the defined behaviour? Yes, it is, but only since Q 7.1. The general rule is that, while special arguments of a function will never be evaluated, deferred subterms inside a _non-special_ arg are evaluated automatically when they are needed in the pattern matching process. This is a convenience so that non-special functions can assume matched subterms to be in (weak) normal form, which is important to make functions operating on lazy data structures such as streams do the right thing. For instance, consider the following definition: deinterleave {} = {}; deinterleave {X,Y|Xs} = {(X,Y)|deinterleave Xs}; To match the left-hand side of the second rule (which is actually a shorthand for {X|{Y|Xs}}, the pattern matcher has to evaluate the tail of the actual stream parameter. Note that otherwise this equation would never match a stream with deferred tail like {1..} = {1|iterate (+1) ((+1) 1)}. This only happens when a pattern reaches inside a deferred subterm. If you have an equation like test 'X = '(X+1); then X is _not_ evaluated, because it is unnecessary to decide the match: ==> test '(2 + 3) '(2+3+1) But in your example test '(A B) = ('A, 'B); the pattern reaches inside the argument of ('), so the pattern matcher evaluates the argument to decide whether this value is an application or not. (') is handled just like any other special data constructor here. OTOH, if you make test itself a special form, then argument evaluation is always inhibited and arguments are passed as is. So the following will do what you want: special test X; test '(A B) = ('A, 'B); Example: ==> test '(a (2 + 3)) ('a,'(2+3)) I know that this is somewhat confusing, and in a program I recently wrote I also ran into the very same trap. ;-) But this new "call by need" way of doing pattern matching makes defining functions operating on lazy data structures so much more convenient. > Also, when using the Q interpreter to write scripts, it always prints > the last object to stdout. Is there an option to turn it off? If > I want to write a script that outputs some text, I wouldn't want the > output to be clobbered with an object. Explicitly exiting from the program with `exit 0' probably does what you want. 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: Kristof B. <kr...@vl...> - 2006-08-01 15:56:06
|
Hi, first I'd like to say that Q is an interesting language, and it is surprising to find such a complete documentation for a relatively unknown language. I find special forms particularly interesting. I wrote part of a library to write html pages as expressions, where you can write an html tag as function application (like scheme sxml). For example: (to_html (html (head (title ~Homepage)) (body (h1 ~Title) (a (href = "www.url.org/adress") "ref")))) => a nested html object However I came across the following strange behaviour. In the equation: test '(A B) = ('A, 'B); I would expect test '(a (2 + 3)) to evaluate to ('a, '(2 + 3)), however it evaluates to ('a, '5). Is this the defined behaviour? I would think that quote is a special form which doesn't evaluate it's argument. Also, when using the Q interpreter to write scripts, it always prints the last object to stdout. Is there an option to turn it off? If I want to write a script that outputs some text, I wouldn't want the output to be clobbered with an object. Regards, Kristof Bastiaensen |
From: Qiana B. <q....@th...> - 2006-07-24 22:32:31
|
From: John C. <co...@cc...> - 2006-07-24 21:21:52
|
Albert Graef scripsit: > So, if you have an expression of the form bin X T1 T2 you can still be > sure that it is a normal form. I guess that this solves your problem? Yes, it does. Thanks. > OTOH, the following equation is now valid: > > bin X T1 T2 Y = ...; > > Which makes sense if you want to also be able to use an (essentially > equivalent) equation like: > > T:Bintree Y = ...; Good. -- Yes, chili in the eye is bad, but so is your John Cowan ear. However, I would suggest you wash your co...@cc... hands thoroughly before going to the toilet. http://www.ccil.org/~cowan --gadicath |
From: Albert G. <Dr....@t-...> - 2006-07-24 11:50:11
|
John Cowan wrote: > This makes me a bit nervous. Would it be possible to distinguish > between constants and constructors, and allow a constant in the head > (but not all constants) while still forbidding a constructor? That would be a rather arbitrary distinction between constructors of zero and nonzero arity. > The whole point of constructors is that the application of a constructor > is guaranteed to be in normal form. Given a declaration like "type BinTree = const bin X T1 T2;" you still have that the following equations are all forbidden: bin = ...; bin X = ...; bin X T1 = ...; bin X T1 T2 = ...; So, if you have an expression of the form bin X T1 T2 you can still be sure that it is a normal form. I guess that this solves your problem? OTOH, the following equation is now valid: bin X T1 T2 Y = ...; Which makes sense if you want to also be able to use an (essentially equivalent) equation like: T:Bintree Y = ...; I've already implemented it that way, and I've also updated the documentation in qdoc.texi. Seems to work nicely so far. If you want to try it out, just get yourself the latest qcrules.c from cvs and recompile. 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: John C. <co...@cc...> - 2006-07-24 11:25:00
|
Albert Graef scripsit: > Considering the potential use of application as a kind of "default > operator", as you discussed, I'm beginning to wonder whether this > constraint, that a const value cannot occur in the head of a lhs, is a > bit too strict. Maybe the constraint should actually be "the (entire) > lhs must not be a const", so that constructor equations like [1,2,3] = > [] are still forbidden, but not applications involving a const in the > head like [X|Xs] Y = ...? > > I actually like this idea. It would cure the inconsistency I described > in my previous post, and I'd say that it also follows the principle of > the least surprise; there's no real reason why a constant data object > cannot be something that acts like a function which can be applied to an > argument. Of course, this also gives you a bigger gun to shoot yourself > in the foot... But, as Keith rightfully pointed out, Q is not a "safer > programming" language anyway. This makes me a bit nervous. Would it be possible to distinguish between constants and constructors, and allow a constant in the head (but not all constants) while still forbidding a constructor? The whole point of constructors is that the application of a constructor is guaranteed to be in normal form. -- What is the sound of Perl? Is it not the John Cowan sound of a [Ww]all that people have stopped co...@cc... banging their head against? --Larry http://www.ccil.org/~cowan |
From: Keith T. <kaz...@ea...> - 2006-07-24 08:54:45
|
--- Albert Graef writes: - Maybe the constraint should actually be "the (entire) lhs must - not be a const", so that constructor equations like [1,2,3] = [] - are still forbidden, but not applications involving a const in the - head like [X|Xs] Y = ...? - - [snip!] - - I actually like this idea. Me too. - This also gives you a bigger gun to shoot yourself in the foot... If it is a _well-documented_ gun, then it should not be a problem. Cheers, Keith |
From: Albert G. <Dr....@t-...> - 2006-07-24 07:44:19
|
John Cowan wrote: > Albert Graef scripsit: > >>4. be happy that Q still leaves some dirty tricks to be discovered by >>the master Q programmer ;-) > > Indeed, though I think this particular trick could now be documented > in the manual. Yes, there should be a list of exactly what can and what cannot occur on the lhs of an equation. I already put this on my TODO list. Considering the potential use of application as a kind of "default operator", as you discussed, I'm beginning to wonder whether this constraint, that a const value cannot occur in the head of a lhs, is a bit too strict. Maybe the constraint should actually be "the (entire) lhs must not be a const", so that constructor equations like [1,2,3] = [] are still forbidden, but not applications involving a const in the head like [X|Xs] Y = ...? I actually like this idea. It would cure the inconsistency I described in my previous post, and I'd say that it also follows the principle of the least surprise; there's no real reason why a constant data object cannot be something that acts like a function which can be applied to an argument. Of course, this also gives you a bigger gun to shoot yourself in the foot... But, as Keith rightfully pointed out, Q is not a "safer programming" language anyway. 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 |