q-lang-users Mailing List for Q - Equational Programming Language (Page 48)
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: John C. <co...@cc...> - 2006-02-08 03:17:02
|
Albert Graef scripsit: > >Thanks for responding so quickly. Unfortunately, these aren't the > >clearest of instructions. I tried adding "$(LIBICONV)" to the definition > > Hmm, that should probably be $(LTLIBICONV), can you post the two > definitions please? They are defined identically as "-liconv". > Hmm, looks like automake tries to execute autoconf (maybe wants to get > the autoconf version?) and doesn't find it. Is autoconf/automake working > with other programs? You could also try to fix the corresponding > Makefile.in's instead, add the proper link options manually and then > rerun configure, if automake doesn't work for you. (But see below.) I've never tried to run automake before, so I don't really know. At most I've installed patches into Makefile.in. > Yes, clearly the proper link option for libiconv is missing. So I'll > have to add a corresponding LIBADD line in libq/Makefile.am and also > modify the LIBADD lines in the other Makefile.am's I mentioned. If you > can wait a little more, I'll try to figure out what the right @XYZ@ > variables are which have to be included for libiconv and libgettext, and > then prepare a new tarball. This is a new box and my first attempt to install 7.0, so there's no hurry. -- Possession is said to be nine points of the law, John Cowan but that's not saying how many points the law might have. co...@cc... --Thomas A. Cowan (law professor and my father |
From: Albert G. <Dr....@t-...> - 2006-02-07 18:35:05
|
John Cowan wrote: > Thanks for responding so quickly. Unfortunately, these aren't the > clearest of instructions. I tried adding "$(LIBICONV)" to the definition Hmm, that should probably be $(LTLIBICONV), can you post the two definitions please? > of libq_la_LDFLAGS in libq/Makefile.am, but then was roadblocked: > "automake" crashes with "automake: `configure.ac' or `configure.in' Yep, for libq/Makefile.am, automake needs to be run in the main source dir. Or you can try to just run autogen.sh, that should rebuild the entire configury (but probably that won't work either, given that automake gives you the troubles you mentioned below). > is required", and trying it in the q-7.0 root directory crashes with > "sh: autoconf: command not found". Hmm, looks like automake tries to execute autoconf (maybe wants to get the autoconf version?) and doesn't find it. Is autoconf/automake working with other programs? You could also try to fix the corresponding Makefile.in's instead, add the proper link options manually and then rerun configure, if automake doesn't work for you. (But see below.) > Here's the current state of what make (in the root) says: > /bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o libq.la -rpath /usr/local/lib -no-undefined -version-info 7:0:0 libq.lo -lcrypt -lutil -lm > rm -fr .libs/libq.dll.a > gcc -shared .libs/libq.o -lcrypt -lutil -o .libs/cygq-7.dll -Wl,--image-base=0x10000000 -Wl,--out-implib,.libs/libq.dll.a > Creating library file: .libs/libq.dll.a > .libs/libq.o: In function `from_utf8': > /opt/q-7.0/libq/libq.c:508: undefined reference to `_libiconv_open' > /opt/q-7.0/libq/libq.c:539: undefined reference to `_libiconv' > /opt/q-7.0/libq/libq.c:563: undefined reference to `_libiconv' > /opt/q-7.0/libq/libq.c:568: undefined reference to `_libiconv_close' Yes, clearly the proper link option for libiconv is missing. So I'll have to add a corresponding LIBADD line in libq/Makefile.am and also modify the LIBADD lines in the other Makefile.am's I mentioned. If you can wait a little more, I'll try to figure out what the right @XYZ@ variables are which have to be included for libiconv and libgettext, and then prepare a new tarball. 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-02-06 23:24:03
|
Albert Graef scripsit: > looks like I forgot about LIBICONV because here on Linux I have iconv in > libc. In principle, adding $(LIBICONV) or $(LTLIBICONV) to the link > lines of compiler and interpreter (src/Makefile.am), libq > (libq/Makefile.am) and clib (modules/clib/Makefile.am) should do the > trick. Something similar will be needed to make clib::gettext and > friends work. If that doesn't help then please post the complete make > log so that we can figure out what exactly goes wrong. Thanks for responding so quickly. Unfortunately, these aren't the clearest of instructions. I tried adding "$(LIBICONV)" to the definition of libq_la_LDFLAGS in libq/Makefile.am, but then was roadblocked: "automake" crashes with "automake: `configure.ac' or `configure.in' is required", and trying it in the q-7.0 root directory crashes with "sh: autoconf: command not found". Attempts to do "make Makefile.in" report that it is up to date, and "make Makefile" says there is no such target. Here's the current state of what make (in the root) says: $ make make all-recursive make[1]: Entering directory `/opt/q-7.0' Making all in . make[2]: Entering directory `/opt/q-7.0' make[2]: Leaving directory `/opt/q-7.0' Making all in libltdl make[2]: Entering directory `/opt/q-7.0/libltdl' make all-am make[3]: Entering directory `/opt/q-7.0/libltdl' make[3]: Leaving directory `/opt/q-7.0/libltdl' make[2]: Leaving directory `/opt/q-7.0/libltdl' Making all in glob make[2]: Entering directory `/opt/q-7.0/glob' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/opt/q-7.0/glob' Making all in regex make[2]: Entering directory `/opt/q-7.0/regex' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/opt/q-7.0/regex' Making all in doc make[2]: Entering directory `/opt/q-7.0/doc' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/opt/q-7.0/doc' Making all in etc make[2]: Entering directory `/opt/q-7.0/etc' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/opt/q-7.0/etc' Making all in examples make[2]: Entering directory `/opt/q-7.0/examples' make[2]: Nothing to be done for `all'. make[2]: Leaving directory `/opt/q-7.0/examples' Making all in libq make[2]: Entering directory `/opt/q-7.0/libq' /bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o libq.la -rpath /usr/local/lib -no-undefined -version-info 7:0:0 libq.lo -lcrypt -lutil -lm rm -fr .libs/libq.dll.a gcc -shared .libs/libq.o -lcrypt -lutil -o .libs/cygq-7.dll -Wl,--image-base=0x10000000 -Wl,--out-implib,.libs/libq.dll.a Creating library file: .libs/libq.dll.a .libs/libq.o: In function `from_utf8': /opt/q-7.0/libq/libq.c:508: undefined reference to `_libiconv_open' /opt/q-7.0/libq/libq.c:539: undefined reference to `_libiconv' /opt/q-7.0/libq/libq.c:563: undefined reference to `_libiconv' /opt/q-7.0/libq/libq.c:568: undefined reference to `_libiconv_close' .libs/libq.o: In function `to_utf8': /opt/q-7.0/libq/libq.c:587: undefined reference to `_libiconv_open' /opt/q-7.0/libq/libq.c:618: undefined reference to `_libiconv' /opt/q-7.0/libq/libq.c:623: undefined reference to `_libiconv_close' .libs/libq.o: In function `file_from_utf8': /opt/q-7.0/libq/libq.c:676: undefined reference to `_libiconv' /opt/q-7.0/libq/libq.c:643: undefined reference to `_libiconv_open' .libs/libq.o: In function `file_to_utf8': /opt/q-7.0/libq/libq.c:728: undefined reference to `_libiconv' /opt/q-7.0/libq/libq.c:698: undefined reference to `_libiconv_open' .libs/libq.o: In function `file_encoding': /opt/q-7.0/libq/libq.c:778: undefined reference to `_libiconv_close' /opt/q-7.0/libq/libq.c:765: undefined reference to `_libiconv_close' /opt/q-7.0/libq/libq.c:750: undefined reference to `_libiconv_open' /opt/q-7.0/libq/libq.c:751: undefined reference to `_libiconv_open' /opt/q-7.0/libq/libq.c:754: undefined reference to `_libiconv_close' /opt/q-7.0/libq/libq.c:756: undefined reference to `_libiconv_close' collect2: ld returned 1 exit status make[2]: *** [libq.la] Error 1 make[2]: Leaving directory `/opt/q-7.0/libq' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/opt/q-7.0' make: *** [all] Error 2 -- Babies are born as a result of the John Cowan mating between men and women, and most http://www.reutershealth.com men and women enjoy mating. http://www.ccil.org/~cowan --Isaac Asimov in Earth: Our Crowded Spaceship co...@cc... |
From: WW <w_...@ea...> - 2006-02-06 22:47:10
|
http://www.tiobe.com/tpci.htm - at number 49. Regards, Walter |
From: Albert G. <Dr....@t-...> - 2006-02-06 22:45:40
|
John Cowan wrote: > My attempt to build 7.0 on Cygwin failed because _libiconv_open and > _libiconv_close weren't found when trying to build libq.la. I have > libiconv installed under Cygwin, so patching around this is probably a > matter of inserting a strategic "-liconv" into the Makefile somewhere. > It's already mentioned in the defines for LIBICONV, LTLIBICONV, and > XML_LIBS; adding it to LIBS and LDFLAGS didn't help any. > > I presume the fix is simple, though. Can anyone help? Hi John, looks like I forgot about LIBICONV because here on Linux I have iconv in libc. In principle, adding $(LIBICONV) or $(LTLIBICONV) to the link lines of compiler and interpreter (src/Makefile.am), libq (libq/Makefile.am) and clib (modules/clib/Makefile.am) should do the trick. Something similar will be needed to make clib::gettext and friends work. If that doesn't help then please post the complete make log so that we can figure out what exactly goes wrong. 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-02-06 22:00:17
|
Albert Graef scripsit: > it took much too long, but at long last I finished unicode support in > the Q interpreter and the core modules. Hurrah! > Windows users: sorry, but you will have to wait a little more, I hope I > get around porting the new release this week. I also want to check other > platforms such as OS X asap, and I still have to overhaul the add-on > modules (multimedia library etc.) to make them unicode-aware. (Another > big item on my TODO list which didn't make it into the 7.0 release yet > is 64 bit support, I'm afraid that this will have to wait until Q 7.1.) My attempt to build 7.0 on Cygwin failed because _libiconv_open and _libiconv_close weren't found when trying to build libq.la. I have libiconv installed under Cygwin, so patching around this is probably a matter of inserting a strategic "-liconv" into the Makefile somewhere. It's already mentioned in the defines for LIBICONV, LTLIBICONV, and XML_LIBS; adding it to LIBS and LDFLAGS didn't help any. I presume the fix is simple, though. Can anyone help? -- You escaped them by the will-death John Cowan and the Way of the Black Wheel. co...@cc... I could not. --Great-Souled Sam http://www.ccil.org/~cowan |
From: <in...@nn...> - 2006-02-06 14:49:40
|
/////////////////////////////////////////////////////////////////////// $B!z!y!z:#$^$G=P2q$$7O%5%$%H$NA*$SJ}4V0c$C$F$^$;$s$+!)!z!y!z(B /////////////////////////////////////////////////////////////////////// $B%a%kM'Jg=8$N%5%$%H$G$O%a!<%k$@$1$G<B:]$K$O=P2q$($^$;$s!#(B $B3d$j@Z$C$?4X78!"3d$j@Z$i$J$$4X78!"$I$A$i$b=P2q$C$F$+$i$N;O$^$j$G$9!#(B $B!yL5NA%]%$%s%H#1#2#0#0#01_J,!y(B $B!z$b$A$m$sL5NA%]%$%s%H$G%"%I%l%98r49$b#O#K$G$9!z(B $B!z2<5-%5%$%H$G$N%@%i%a$O5,Ls0cH?$G$9$h!z(B http://nncom.info/wty/ //////////////////////////////////////////////////// $BITMW$NJ}$O%3%A%i$^$G(B in...@ok... |
From: Albert G. <Dr....@t-...> - 2006-02-06 05:04:58
|
Hi, it took much too long, but at long last I finished unicode support in the Q interpreter and the core modules. As a bonus, I also threw in a new GUI builder which generates native Q code and is based on Peter G. Baum's Gnocl, a very nice Tcl extension for building GNOME/GTK+ applications (http://gnocl.sf.net). I have already been testing the new release on my Linux development box for some weeks, and the unicode stuff seems to work o.k., at least in utf8 and latin1 locales. But due to the complex nature of the changes, I'm first releasing a candidate, in the hope that at least some of you can do some more testing. In particular, it would be nice if those of you who work in non-Western locales could give the new release a whirl (do we have any Q programmers from the Far East on the list?), so that bugs can be weeded out before the final release. Windows users: sorry, but you will have to wait a little more, I hope I get around porting the new release this week. I also want to check other platforms such as OS X asap, and I still have to overhaul the add-on modules (multimedia library etc.) to make them unicode-aware. (Another big item on my TODO list which didn't make it into the 7.0 release yet is 64 bit support, I'm afraid that this will have to wait until Q 7.1.) The q-7.0rc1 tarball is available for download here: http://sourceforge.net/project/showfiles.php?group_id=96881&package_id=103965 And you can find the release notes here: http://sourceforge.net/project/shownotes.php?release_id=391246&group_id=96881 A screenshot of the new GUI builder is available here: http://q-lang.sourceforge.net/gqbuilder.png Enjoy! :) 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: <con...@uu...> - 2006-01-13 16:34:01
|
$B5.J}MM$H2q$$$?$$$H$$$&=w@-2q0wMM$,$*$j$^$9!#(B $B"'$*JV;v$3$A$i$+$i"'(B http://311.send-mail.info/kanzen_muryo.php?id=35q76jhfgd8gl7yjs $B$$$D$b$4MxMQD:$$$F@?$KM-Fq$&8f:B$$$^$9!#(B $B%5%$%H%j%K%e!<%"%k$KH<$$!":FEPO?<jB3$-$,I,MW$G$9!#(B $B$^$?!"#1#0#0#0#01_J,$NL5NA%]%$%s%H$b$4MQ0U$7$F$*$j$^$9$N$G$<$R:FEPO?<jB3$-$r:Q$^$;$F$/$@$5$$!#(B http://311.send-mail.info/kanzen_muryo.php?id=i479fgd8glfgh75kwhg $B"(%o%s%/%j%C%/!&ITEv@A5aEy$G$O$"$j$^$;$s$N$G!"0B?4$7$F$4MxMQ$/$@$5$$!#(B $B:FEPO?$,I,MW$N$J$$J}$O(B con...@uu... |
From: Albert G. <Dr....@t-...> - 2006-01-08 05:25:47
|
Arnoldo Jose Muller Molina wrote: > Just after sending the e-mail it occurred to me that Q wasn't publishing > the symbols I was using when matching, so I changed t2.q to: Exactly. :) In the interpreter you're always in the namespace of the main script you're running. You were running t2, t1 doesn't export those symbols to t2 => same identifier will refer to a different symbol in the namespace of the main script (that symbol is created by the interpreter on the fly). Exactly like it's supposed to be. When in doubt, try the whos command: ==> whos fcondition fcondition not a defined symbol If the interpreter actually knows the symbol then whos will show you the module in which it is defined. ==> whos map map function symbol defined in /usr/share/q/lib/stdlib.q map $1 $2 > public fcondition; > public parameterRef; > public methodRef; > public fieldRef; > public ftype; > public localRef; Of course you could just write: public fcondition, parameterRef, methodRef, fieldRef, ftype, localRef; > Now it works... Would this be the best solution? Well, it looks like your symbols are actually supposed to be constants, so why not turn them into an enumeration type: public type FSpec = const fcondition, parameterRef, methodRef, fieldRef, ftype, localRef; Then you can just write: fspec _:FSpec = true; fspec _ = false otherwise; As another nice side effect, you can now also compare the FSpec values using (=), (<) etc. :) HTH, 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: Arnoldo J. M. M. <ar...@da...> - 2006-01-08 04:10:16
|
Hello All, Just after sending the e-mail it occurred to me that Q wasn't publishing the symbols I was using when matching, so I changed t2.q to: ///////////////////// public fspec; // change: (* x *)V public fcondition; public parameterRef; public methodRef; public fieldRef; public ftype; public localRef; // change: (* x *)V fspec(fcondition) = true; fspec(parameterRef) = true; fspec(methodRef) = true; fspec(fieldRef) = true; fspec(ftype) = true; fspec(localRef) = true; fspec(_) = false; ///////////////////// Now it works... Would this be the best solution? Thanks again! Best regards, AJMM. On Sun, 2006-01-08 at 13:02 +0900, Arnoldo Jose Muller Molina wrote: > Dear All, > > Thank you so much for all your previous help. Thanks to your advice I've > been able to understand Q better. Every day I like Q more and more! > (* x *)V > > > I have two files: > t1.q: > //////////////////////////// > public fspec; > > fspec(fcondition) = true; > fspec(parameterRef) = true; > fspec(methodRef) = true; > fspec(fieldRef) = true; > fspec(ftype) = true; > fspec(localRef) = true; > fspec(_) = false; > //////////////////////////// > > > and t2.q: > //////////////////////////// > import "t1"; > //////////////////////////// > > When I execute the interpreter with "q t1.q" and enter the following: > ==> fspec(localRef) > true > > I will of course get true, > > When I execute the interpreter with "q t2.q" and enter: > ==> fspec(localRef); > false > > I unexpectedly get false... > > Using "debug on" I get the following: > > ==> fspec(localRef); > 0> t1.q, line 10: fspec localRef ==> false > (type ? for help) > : > ** fspec localRef ==> false > false > > (Line 10 is the last rule of the t1.q file) > > What am I doing wrong? If I comment out line 10, Q will not execute the > rule fspec, it's like the fspec rule disappears. > (T _ T) > > Thanks in advance! > > > > > |
From: Arnoldo J. M. M. <ar...@da...> - 2006-01-08 04:03:37
|
Dear All, Thank you so much for all your previous help. Thanks to your advice I've been able to understand Q better. Every day I like Q more and more! (* x *)V I have two files: t1.q: //////////////////////////// public fspec; fspec(fcondition) = true; fspec(parameterRef) = true; fspec(methodRef) = true; fspec(fieldRef) = true; fspec(ftype) = true; fspec(localRef) = true; fspec(_) = false; //////////////////////////// and t2.q: //////////////////////////// import "t1"; //////////////////////////// When I execute the interpreter with "q t1.q" and enter the following: ==> fspec(localRef) true I will of course get true, When I execute the interpreter with "q t2.q" and enter: ==> fspec(localRef); false I unexpectedly get false... Using "debug on" I get the following: ==> fspec(localRef); 0> t1.q, line 10: fspec localRef ==> false (type ? for help) : ** fspec localRef ==> false false (Line 10 is the last rule of the t1.q file) What am I doing wrong? If I comment out line 10, Q will not execute the rule fspec, it's like the fspec rule disappears. (T _ T) Thanks in advance! |
From: Sheehy, M. (MH) <mar...@ma...> - 2005-12-28 04:50:19
|
Thanks very much for your detailed response. It is greatly appreciated. Greg -----Original Message----- From: q-l...@li... [mailto:q-l...@li...] Sent: Wednesday, 28 December 2005 3:29 PM To: q-l...@li... Subject: q-lang-users digest, Vol 1 #140 - 2 msgs Send q-lang-users mailing list submissions to q-l...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/q-lang-users or, via email, send a message with subject or body 'help' to q-l...@li... You can reach the person managing the list at q-l...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of q-lang-users digest..." Today's Topics: 1. Re: newbie question: Efficiency & other stuff (Albert Graef) 2. Re: Newbie: Backtracking again (Albert Graef) --__--__-- Message: 1 Date: Tue, 27 Dec 2005 09:40:52 +0100 From: Albert Graef <Dr....@t-...> To: q-l...@li... Subject: Re: [q-lang-users] newbie question: Efficiency & other stuff Reply-To: q-l...@li... Arnoldo Jose Muller Molina wrote: > dmatch(E1,E2) = (#expand(E1) + #expand(E2)) - (2 * dmatchAux(expand > (E1),expand(E2))); As Q functions may have side effects, it is not possible to optimize away shared subexpressions like this. That's what where clauses are for. Try something like: dmatch(E1,E2) = (#X1 + #X2) - (2 * dmatchAux(X1,X2)) where X1 = expand(E1), X2 = expand(E2); > I have executed some stats commands after executing this rule, with and > without the "(#expand(E1) + #expand(E2))" and it seems that q is > calculating expand(E1) and expand(E2) 2 times (1). > > 1) Is this true? > > 2) if that is so, is there a way of implementing a "let" so I can > compute only once the results of expand(_)? Of course I could create an > elaborate chain of rules and allow this, but is there a way that doesn't > involve creating several rules? > > Thank you! > > -------------------------- > (1) (expand(...) is a deterministic rule, it will always return the same > result for the same input) -- 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 --__--__-- Message: 2 Date: Tue, 27 Dec 2005 10:47:55 +0100 From: Albert Graef <Dr....@t-...> To: q-l...@li... CC: Gre...@ma... Subject: Re: [q-lang-users] Newbie: Backtracking again Reply-To: q-l...@li... Mele, Greg (MH) wrote: > I dont understand the queens algorithm enough to see how backtracking > works by the fail instruction. > > I would like to have a prolog-like system: > ie the classic genealogical database > > > father(a,b). > father(b,c). > father(c,d). > > ancestor(X,Y) :- father (X,Z), ancestor (Z,Y). Prolog uses both unification and backtracking to solve problems like this. Of course you could do something similar in Q, but it would essentially amount to writing a simple Prolog interpreter in Q. I won't go into this here, but I'll try to explain the workings of the fail construct in the following. The fail instruction is only useful to implement backtracking, without the unification part. It just tells the interpreter that the current equation has failed, so that it moves on to the next applicable equation. E.g., if you have two equations like this: foo = writes "foo#1\n" || fail; foo = writes "foo#2\n"; and you evaluate `foo' then the interpreter first starts evaluating the right-hand side of the first rule. After printing out "foo#1", it will evaluate the `fail', causing the first rule to fail. Now the second rule gets executed, printing "foo#2". So the end result would be the following printout: foo#1 foo#2 (I also often use this trick for debugging purposes. E.g., if you have a function bar X with a bunch of defining equations, then simply putting an equation like bar X = printf "bar invoked with arg %s\n" (str X) || fail; in front of those equations allows you to print bar's argument whenever it is invoked, after which the bar X call is evaluated as usual.) Ok, now how does the queens example work? Let's take a look at the crucial definition of the search function (which is invoked as search N 1 1 [] from queens N): search N I J P = write P || writes "\n" if I>N; = search N (I+1) 1 (P++[(I,J)]) || fail if safe (I,J) P; = search N I (J+1) P if J<N; = () otherwise; N is the size of the board (number of rows/columns), I the current row, J the current column and P the list of places (row/column pairs) of the queens determined so far (in rows 0..I-1 of the board). The first equation simply checks whether we've already found a solution (I>N implies that #P=N) which is printed out. The second equation is where the backtracking actually happens. If it is safe to place the next queen at position (I,J), w.r.t. the places P we already have, then we add (I,J) to P and invoke the algorithm recursively starting at column 1 in the next row. After returning from the recursive call, the entire subspace of the solution space with the given placements P++[(I,J)] has been covered. Now we let the equation fail, so that the interpreter moves on to the third equation to try other columns for the Ith row. In any case (i.e., also if the second equation is skipped because (I,J) is not safe), the third equation moves on to the next column J+1 and invokes the algorithm recursively. This only happens if J<N, otherwise there are no other potential placements for the Ith row in which case the fourth equation returns (). Note that the third equation is tail-recursive, i.e., it is essentially just a loop which iterates over the different columns for the same row I. The second equation is where the algorithm recursively descends into the solution subspace for a given initial placement. Well, I hope that this clarifies the inner workings of the algorithm a bit. Tracing the algorithm for a small value of N (either on paper or with the interpreter's debugger) also helps. ;-) 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 --__--__-- _______________________________________________ q-lang-users mailing list q-l...@li... https://lists.sourceforge.net/lists/listinfo/q-lang-users End of q-lang-users Digest THIS E-MAIL IS CONFIDENTIAL. If you have received this e-mail in error, please notify us by return e-mail and delete the document. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. Eastern Health is not liable for the proper and complete transmission of the information contained in this communication or for any delay in its receipt. |
From: Albert G. <Dr....@t-...> - 2005-12-27 09:44:10
|
Mele, Greg (MH) wrote: > I dont understand the queens algorithm enough to see how backtracking > works by the fail instruction. > > I would like to have a prolog-like system: > ie the classic genealogical database > > > father(a,b). > father(b,c). > father(c,d). > > ancestor(X,Y) :- father (X,Z), ancestor (Z,Y). Prolog uses both unification and backtracking to solve problems like this. Of course you could do something similar in Q, but it would essentially amount to writing a simple Prolog interpreter in Q. I won't go into this here, but I'll try to explain the workings of the fail construct in the following. The fail instruction is only useful to implement backtracking, without the unification part. It just tells the interpreter that the current equation has failed, so that it moves on to the next applicable equation. E.g., if you have two equations like this: foo = writes "foo#1\n" || fail; foo = writes "foo#2\n"; and you evaluate `foo' then the interpreter first starts evaluating the right-hand side of the first rule. After printing out "foo#1", it will evaluate the `fail', causing the first rule to fail. Now the second rule gets executed, printing "foo#2". So the end result would be the following printout: foo#1 foo#2 (I also often use this trick for debugging purposes. E.g., if you have a function bar X with a bunch of defining equations, then simply putting an equation like bar X = printf "bar invoked with arg %s\n" (str X) || fail; in front of those equations allows you to print bar's argument whenever it is invoked, after which the bar X call is evaluated as usual.) Ok, now how does the queens example work? Let's take a look at the crucial definition of the search function (which is invoked as search N 1 1 [] from queens N): search N I J P = write P || writes "\n" if I>N; = search N (I+1) 1 (P++[(I,J)]) || fail if safe (I,J) P; = search N I (J+1) P if J<N; = () otherwise; N is the size of the board (number of rows/columns), I the current row, J the current column and P the list of places (row/column pairs) of the queens determined so far (in rows 0..I-1 of the board). The first equation simply checks whether we've already found a solution (I>N implies that #P=N) which is printed out. The second equation is where the backtracking actually happens. If it is safe to place the next queen at position (I,J), w.r.t. the places P we already have, then we add (I,J) to P and invoke the algorithm recursively starting at column 1 in the next row. After returning from the recursive call, the entire subspace of the solution space with the given placements P++[(I,J)] has been covered. Now we let the equation fail, so that the interpreter moves on to the third equation to try other columns for the Ith row. In any case (i.e., also if the second equation is skipped because (I,J) is not safe), the third equation moves on to the next column J+1 and invokes the algorithm recursively. This only happens if J<N, otherwise there are no other potential placements for the Ith row in which case the fourth equation returns (). Note that the third equation is tail-recursive, i.e., it is essentially just a loop which iterates over the different columns for the same row I. The second equation is where the algorithm recursively descends into the solution subspace for a given initial placement. Well, I hope that this clarifies the inner workings of the algorithm a bit. Tracing the algorithm for a small value of N (either on paper or with the interpreter's debugger) also helps. ;-) 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-...> - 2005-12-27 08:37:01
|
Arnoldo Jose Muller Molina wrote: > dmatch(E1,E2) = (#expand(E1) + #expand(E2)) - (2 * dmatchAux(expand > (E1),expand(E2))); As Q functions may have side effects, it is not possible to optimize away shared subexpressions like this. That's what where clauses are for. Try something like: dmatch(E1,E2) = (#X1 + #X2) - (2 * dmatchAux(X1,X2)) where X1 = expand(E1), X2 = expand(E2); > I have executed some stats commands after executing this rule, with and > without the "(#expand(E1) + #expand(E2))" and it seems that q is > calculating expand(E1) and expand(E2) 2 times (1). > > 1) Is this true? > > 2) if that is so, is there a way of implementing a "let" so I can > compute only once the results of expand(_)? Of course I could create an > elaborate chain of rules and allow this, but is there a way that doesn't > involve creating several rules? > > Thank you! > > -------------------------- > (1) (expand(...) is a deterministic rule, it will always return the same > result for the same input) -- 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: Arnoldo J. M. M. <ar...@da...> - 2005-12-27 02:24:12
|
Hello All, I have this piece of code: dmatch(E1,E2) = (#expand(E1) + #expand(E2)) - (2 * dmatchAux(expand (E1),expand(E2))); I have executed some stats commands after executing this rule, with and without the "(#expand(E1) + #expand(E2))" and it seems that q is calculating expand(E1) and expand(E2) 2 times (1). 1) Is this true? 2) if that is so, is there a way of implementing a "let" so I can compute only once the results of expand(_)? Of course I could create an elaborate chain of rules and allow this, but is there a way that doesn't involve creating several rules? Thank you! -------------------------- (1) (expand(...) is a deterministic rule, it will always return the same result for the same input) |
From: Mele, G. (MH) <Gre...@ma...> - 2005-12-12 00:26:01
|
Thanks in advance. I dont understand the queens algorithm enough to see how backtracking works by the fail instruction. I would like to have a prolog-like system: ie the classic genealogical database father(a,b). father(b,c). father(c,d). ancestor(X,Y) :- father (X,Z), ancestor (Z,Y). Is this possible? Or is there another simple example of backtracking using the fail instruction that I could ponder over? Greg THIS E-MAIL IS CONFIDENTIAL. If you have received this e-mail in error, please notify us by return e-mail and delete the document. If you are not the intended recipient you are hereby notified that any disclosure, copying, distribution or taking any action in reliance on the contents of this information is strictly prohibited and may be unlawful. Eastern Health is not liable for the proper and complete transmission of the information contained in this communication or for any delay in its receipt. |
From: Albert G. <Dr....@t-...> - 2005-12-05 08:55:56
|
Hi all, as some of you might already have noticed, I have uploaded quite a few new packages on q-lang.sf.net. All packages have been updated for SuSE 10.0, and new releases are available for SuperCollider (CVS 2005-11-10) and Faust (0.9.5). Moreover, a bugfix release of Q-Faust (1.1-2, source and binary RPMs) has been uploaded. As usual, you can get all the good new stuff from the Download page (http://q-lang.sf.net/download.html). Please also note that I currently have no means to update the Fedora packages, so these are not listed on the Download page any longer. (You can still find the old FC1 packages in the download area at http://sourceforge.net/project/showfiles.php?group_id=96881, though, and I'll upload new Fedora packages as soon as I get around installing the latest FC release. In the meantime, if anyone can help providing up-to-date packages from some reasonably recent FC release, please let me know.) Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Albert G. <Dr....@t-...> - 2005-11-13 17:09:42
|
Albert Graef wrote: > here is an sqlite3 module which I quickly hacked together over the > weekend. Hope it's useful for some. Unpack, run make and you should be > set. A little example is included. > > I'll officially release this later when I have some time... Release 1.0 is now available from http://q-lang.sf.net. -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Albert G. <Dr....@t-...> - 2005-11-07 07:46:43
|
Hi, here is an sqlite3 module which I quickly hacked together over the weekend. Hope it's useful for some. Unpack, run make and you should be set. A little example is included. I'll officially release this later when I have some time... Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Albert G. <Dr....@t-...> - 2005-10-29 08:34:56
|
Brian Wilfley wrote: > I just realized you wanted to know about g++. Its version is 3.4.2. Ok, thanks. That seems to be a fairly new version. I just wanted to make sure that I don't break any recent setups with the patch. -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Brian W. <bwi...@tr...> - 2005-10-29 04:40:07
|
I just realized you wanted to know about g++. Its version is 3.4.2. bpw On 10/13/05, Albert Graef <Dr....@t-...> wrote: > Hi Brian, > > I'm about to commit your suggested patch to cvs now. Just to make sure: > Which version of mingw/g++ did you use? 2.95.x? 3.x? > > Brian Wilfley wrote: > > Here's what I've figured out: > > > > 1) The quoted errors can be "fixed" with the following patch to libq.h: > > ----------------- patch.libq.h ---------------------- > > *** libq.1.6.h Wed Oct 20 01:09:42 2004 > > --- libq.h Fri Aug 26 15:38:04 2005 > > *************** > > *** 127,135 **** > > --- 127,141 ---- > > > > /* Predefined function and type symbols. */ > > > > + #ifdef __cplusplus > > + __DLLIMPORT int truesym, falsesym, nilsym, voidsym; > > + __DLLIMPORT int inttype, floattype, booltype, strtype, filetype, > > + listtype, tupletype; > > + #else > > __DLLIMPORT const int truesym, falsesym, nilsym, voidsym; > > __DLLIMPORT const int inttype, floattype, booltype, strtype, filetype= , > > listtype, tupletype; > > + #endif > > > > /* Expression construction. */ > > -- > Dr. Albert Gr"af > Dept. of Music-Informatics, University of Mainz, Germany > Email: Dr....@t-..., ag...@mu... > WWW: http://www.musikwissenschaft.uni-mainz.de/~ag > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > q-lang-users mailing list > q-l...@li... > https://lists.sourceforge.net/lists/listinfo/q-lang-users > -- Brian P. Wilfley, Ph.D. Principal Scientist Voice: 650.331.3476 x102 Fax: 650.887.2205 E-mail: bwi...@tr... Triple Ring Technologies, Inc. 1850 Embarcadero Road Palo Alto, CA 94303 |
From: Brian W. <bwi...@tr...> - 2005-10-29 04:39:06
|
Hi Albert, I'm very sorry for the delay in responding. These emails get sorted into folders, and I've not checked this one in a bit. I rummaged around for some version information. I found the following: in c:\MinGW\include\_mingw.h, #define __MINGW32_VERSION 3.7 And running running the "Add/remove Programs" control panel gives version 1.0.10 for MSYS. Let me know if there's anything else I can help with. Brian On 10/13/05, Albert Graef <Dr....@t-...> wrote: > Hi Brian, > > I'm about to commit your suggested patch to cvs now. Just to make sure: > Which version of mingw/g++ did you use? 2.95.x? 3.x? > > Brian Wilfley wrote: > > Here's what I've figured out: > > > > 1) The quoted errors can be "fixed" with the following patch to libq.h: > > ----------------- patch.libq.h ---------------------- > > *** libq.1.6.h Wed Oct 20 01:09:42 2004 > > --- libq.h Fri Aug 26 15:38:04 2005 > > *************** > > *** 127,135 **** > > --- 127,141 ---- > > > > /* Predefined function and type symbols. */ > > > > + #ifdef __cplusplus > > + __DLLIMPORT int truesym, falsesym, nilsym, voidsym; > > + __DLLIMPORT int inttype, floattype, booltype, strtype, filetype, > > + listtype, tupletype; > > + #else > > __DLLIMPORT const int truesym, falsesym, nilsym, voidsym; > > __DLLIMPORT const int inttype, floattype, booltype, strtype, filetype= , > > listtype, tupletype; > > + #endif > > > > /* Expression construction. */ > > -- > Dr. Albert Gr"af > Dept. of Music-Informatics, University of Mainz, Germany > Email: Dr....@t-..., ag...@mu... > WWW: http://www.musikwissenschaft.uni-mainz.de/~ag > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Power Architecture Resource Center: Free content, downloads, discussions, > and more. http://solutions.newsforge.com/ibmarch.tmpl > _______________________________________________ > q-lang-users mailing list > q-l...@li... > https://lists.sourceforge.net/lists/listinfo/q-lang-users > -- Brian P. Wilfley, Ph.D. Principal Scientist Voice: 650.331.3476 x102 Fax: 650.887.2205 E-mail: bwi...@tr... Triple Ring Technologies, Inc. 1850 Embarcadero Road Palo Alto, CA 94303 |
From: Albert G. <Dr....@t-...> - 2005-10-26 06:55:10
|
Arnoldo Jose Muller Molina wrote: > I was reading the manual and it says the matching process explicitly > takes the first (from top to bottom) equation that matches (or the > equation with the highest priority) . Is there a way to make q backtrack > all the possible matchings instead of just the first? Yes. The builtin fail function tells the interpreter to abort the current equation and try the next applicable one. Please see the "8 queens" example in examples/queens2.q and section 10.6 in the manual (http://q-lang.sourceforge.net/qdoc/qdoc_10.html#SEC54). There's also a purely functional way to do this, namely to enumerate the entire solution space as a stream (infinite list) and then traverse that stream to extract the wanted solutions. See examples/queens.q for an example. (But the "dirty" version using fail is usually much faster.) -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikwissenschaft.uni-mainz.de/~ag |
From: Arnoldo J. M. M. <ar...@da...> - 2005-10-26 03:56:34
|
Hi All: I was reading the manual and it says the matching process explicitly takes the first (from top to bottom) equation that matches (or the equation with the highest priority) . Is there a way to make q backtrack all the possible matchings instead of just the first? Thanks in advance, AM. |