From: Albert G. <Dr....@t-...> - 2008-08-15 11:57:52
|
Jeremy Voorhis wrote: > OMG $$++ That gives me a syntax error. ;-) But look at this marvel! > OMG = id; > OMG $ (Im,feeling,silly)!2 $ OMG ponies; silly ponies Ok, I take it that $$ is the consensus. > Regarding tuples, I've always thought of tuples as representing > structures with a fixed number of slots, and that this was a perfectly > valid thing to do. That's what they are, but Pure also allows you to piece them together and manipulate them in any way you see fit. Also, in Haskell et al tuples are a builtin data structure, whereas in Pure they are just an algebraic type like any other (and are in fact completely defined in the prelude). > My Pure abilities are still weak, so somebody help > me out – I assumed tagged tuples would be useful for representing > algebraic types in a dynamic language like Pure, since they are good > for matching on. That's what poor Erlang programmers have to do. In Pure all your data is in fact a term algebra, so any function symbol can act as a constructor and you don't need this kludge. E.g., nil and bin act as constructors in the following example: nullary nil; insert nil y = bin y nil nil; insert (bin x L R) y = bin x (insert L y) R if y<x; = bin x L (insert R y) otherwise; (That works without having to declare anything, except a nullary symbol like nil so that the compiler can distinguish it from a variable when it occurs on the lhs of an eqn.) 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: Libor S. <li...@gm...> - 2008-08-15 11:48:04
|
On Fri, 15 Aug 2008 02:16:40 +0100, Albert Graef <Dr....@t-...> wrote: > Libor Spacek wrote: >> I am not entirely convinced that the tuples are even worth having at all. >> For the minimal (flatness) distinction, they ship in a lot of confusion. > > Can you elaborate on that? The only complication I see is the borked > list-of-tuples syntax, and I'm about to fix that (hopefully!). > Both lists and tuples are devices for ordering and grouping some items. I do not see the problem with using a pair of brackets to make the grouping explicit, as in the list [1,2,3] instead of relying on the precendence of the associativity and using a tuple 1,2,3. I have learnt through painful experience not to rely on remembering the exact precedence of numerous associative operators, especially when I can add my own. Maybe it is just me but when using Pure, I am always worrying: 'is this a tuple or is it a list?' I need to worry about it because selectors and functions will typically work only on one but not on the other. To give a trivial example: head (1..3); // is OK head (1,2,3); // is not OK So, if I return 1,2,3 instead of [1,2,3], everything falls down round my ears. I guess you will say that I ought to know better and you will be right. To complicate things further, I can also in many situations use simply 1 2 3, e.g. >let a = 1 2 3; >a; 1 2 3 So there are three ways of ordering and grouping items which are nearly the same but not quite, which I, at least, find a little bewildering. L. |
From: Albert G. <Dr....@t-...> - 2008-08-15 13:10:50
|
Libor Spacek wrote: > Maybe it is just me but when using Pure, I am always worrying: 'is this a tuple or is it a list?' Ok, I see. But I think that like so many things it's just a matter of practice, getting to know the language. I agree that having an extra tuple type makes things more complex, but, as I tried to point out in a previous post, it also makes some stuff more readable or familiar. If you come from a language like Haskell or Erlang where you're working with tuples all them time, then you'd surely miss them if they weren't provided. Real Lisp men of course don't need all that sugar. ;-) But language design is always a compromise, and every PL is a new exercise to find a certain sweet spot between simplicity, power and convenience. If you leave away everything that's not strictly needed, then you'll end up with combinatorial calculus without any builtins, but who would want to program in such a language? Of course, Pure's tuples being flat is a ... hmm ... speciality that takes some time getting used to. But I wanted to have tuples in Pure for notational convenience, and this was a really cheap way to get them at the cost of just a single infix operator, requiring no builtins at all. So yes, they're an ideosyncrasy, but I dare say that they're also elegant in a way, IMNSHO. > To complicate things further, I can also in many situations use simply 1 2 3, e.g. >> let a = 1 2 3; You don't want to do that. If your first element happens to be a hungry closure then you're busted. :) 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. <er...@bm...> - 2008-08-15 13:03:47
|
On Fri, 2008-08-15 at 12:48 +0100, Libor Spacek wrote: > To complicate things further, I can also in many situations use simply 1 2 3, e.g. > >let a = 1 2 3; > >a; > 1 2 3 Hey Libor, that's cute! Tain't thought of that one. But, ... How do you get at the elements? Would be nice if we could have something like [1 2 3 4] (where the spaces are any white space) without the commas so I could copy and paste from the clipboard straight into the interpreter. That is one great thing about DrScheme: Start with at the prompt > (histogram '()) or whatever function you need. Highlight the data from a Word (Soffice) or Spreadsheet, or Web table, middle button click the stuff between the '() in DrScheme and (histogram '(10 32 34 56 ...)) Except they are 'tabs' or 'end of lines' instead of spaces hit the 'end' key and press 'enter' and watch the magic happen. It's an X thing. Cannot do that with Windoze. e.r. |
From: Albert G. <Dr....@t-...> - 2008-08-17 13:03:56
|
> - First and foremost, I want to see whether I can massage the grammar so > that it becomes possible to write lists of tuples using the special case > syntax [(1,2),(3,4),...]. This is now implemented (r521). Probably the most important single cosmetic change in this release. :) -- 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-...> - 2008-08-18 12:08:08
|
Albert Graef wrote: > - The discussion I had with Libor about how to implement a sequencing > operator ("first x, then y") also kept me thinking, because the solution > I proposed there is not tail-recursive. To do this in a proper way, we'd > need a built-in sequencing operator (special form). While it's not > strictly needed, it's much more convenient than having to write 'y when > _ = x end' all the time. This is now implemented as well. ($$ operator) I'm basically through with my 0.5 TODO list now (Windows port notwithstanding; I can hopefully take a look at that later today). So if anyone is still listening, it would be nice if you could take the latest svn for a test drive. ;-) I also vaguely recall that someone volunteered to write a little test module for math.pure, or did I just dream that up? :) 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. <er...@bm...> - 2008-08-18 13:02:31
|
On Mon, 2008-08-18 at 14:08 +0200, Albert Graef wrote: > Albert Graef wrote: > > - The discussion I had with Libor about how to implement a sequencing > > operator ("first x, then y") also kept me thinking, because the solution > > I proposed there is not tail-recursive. To do this in a proper way, we'd > > need a built-in sequencing operator (special form). While it's not > > strictly needed, it's much more convenient than having to write 'y when > > _ = x end' all the time. > > This is now implemented as well. ($$ operator) > > I'm basically through with my 0.5 TODO list now (Windows port > notwithstanding; I can hopefully take a look at that later today). So if > anyone is still listening, it would be nice if you could take the latest > svn for a test drive. ;-) > > I also vaguely recall that someone volunteered to write a little test > module for math.pure, or did I just dream that up? :) Was that me? I'll see what I can do ASAP. e.r. |
From: Albert G. <Dr....@t-...> - 2008-08-18 16:47:36
|
Eddie Rucker wrote: >> I also vaguely recall that someone volunteered to write a little test >> module for math.pure, or did I just dream that up? :) > > Was that me? I'll see what I can do ASAP. Not sure, but it would be much appreciated anyway. :) -- 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. <er...@bm...> - 2008-08-18 14:56:41
|
Something bad is happening here for the complex numbers: > sqrt (1+:2); 2.23606797749979*cos (t/2)+:2.23606797749979*sin (t/2) the angle t is missing. Another nice way of doing this is: sqrt (x+:y) = sqrt (0.5*(r+a)) +: sqrt (0.5*(r-a)) when r = sqrt x*x+y*y; end; e.r. |
From: Albert G. <Dr....@t-...> - 2008-08-18 17:32:21
|
Eddie Rucker wrote: >> > sqrt (1+:2); >> 2.23606797749979*cos (t/2)+:2.23606797749979*sin (t/2) Oops. Fixed. >> Another nice way of doing this is: >> >> sqrt (x+:y) = sqrt (0.5*(r+a)) +: sqrt (0.5*(r-a)) >> when >> r = sqrt x*x+y*y; >> end; a = ? > Oops. That r should be r = sqrt (x*x+y*y). -- 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-...> - 2008-08-18 17:48:15
|
Eddie Rucker wrote: > IMHO, the following rules should be added for pow: > > pow n::int (x%y) | > pow n::bigint (x%y) | > pow n::double (x%y) = pow n (x/y); Yes, you're right, I've added these now. 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: Eddie R. <er...@bm...> - 2008-08-18 19:41:08
|
On Mon, 2008-08-18 at 19:49 +0200, Albert Graef wrote: > Eddie Rucker wrote: > > IMHO, the following rules should be added for pow: > > > > pow n::int (x%y) | > > pow n::bigint (x%y) | > > pow n::double (x%y) = pow n (x/y); > > Yes, you're right, I've added these now. After the last svn update I'm getting: > using math; > pow 3 (4%3); warning: rule never reduced: pow n::int (x%y) = pow n (x/y); warning: rule never reduced: pow n::bigint (x%y) = pow n (x/y); warning: rule never reduced: pow n::double (x%y) = pow n (x/y); 4.32674871092222 > When I looked in math.pure you have the following rules: pow (x%y) n::int | pow (x%y) n::bigint = pow x n % pow y n if n>0; = pow y (-n) % pow x (-n) if n<0; = 1L%1L otherwise; pow (x%y) n::double = pow (x/y) n; pow (x%y) (n%m) = pow (x/y) (n/m); pow x::int (n%m) | pow x::bigint (n%m) | pow x::double (n%m) = pow x (n/m); pow n::int (x%y) | pow n::bigint (x%y) | pow n::double (x%y) = pow n (x/y); You might want to cut the last three out? e.r. |
From: Eddie R. <er...@bm...> - 2008-08-18 19:30:22
|
Sorry. sqrt (x+:y) = sqrt (0.5*(r+x)) +: sqrt (0.5*(r-x)) when r = sqrt x*x+y*y; end; |
From: Eddie R. <er...@bm...> - 2008-08-18 20:50:02
|
Use to be, 0.5*x produced faster code than x/2.0. Well, I was pleasantly surprised with the assembly output of "gcc -S -O2 test.c" produced exactly the same output. test.c: ------------------------------ #include <stdio.h> int main(void) { double a, b, c; printf("Enter first num:"); scanf("%g", &a); printf("Enter second num:"); scanf("%g", &b); c = a/2.0; printf("%g\n", c); c = 0.5*b; printf("%g\n", c); return 0; } ----------------------------- Portion of the assembly: ----------------------------- call scanf movsd .LC3(%rip), %xmm0 movl $.LC4, %edi movl $1, %eax mulsd 16(%rsp), %xmm0 call printf movsd .LC3(%rip), %xmm0 movl $.LC4, %edi movl $1, %eax mulsd 8(%rsp), %xmm0 call printf e.r. |
From: Albert G. <Dr....@t-...> - 2008-08-18 23:41:31
|
Eddie Rucker wrote: > Use to be, 0.5*x produced faster code than x/2.0. Well, I was pleasantly > surprised with the assembly output of "gcc -S -O2 test.c" produced > exactly the same output. Doesn't make a difference with Pure either, in fact even x/2 runs every bit as fast, and looks nicer. I've committed that version now. -- 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-...> - 2008-08-18 23:15:10
|
Eddie Rucker wrote: > Sorry. > > sqrt (x+:y) = sqrt (0.5*(r+x)) +: sqrt (0.5*(r-x)) > when > r = sqrt x*x+y*y; > end; That looks neat, I think I'm going to use that. :) -- 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. <er...@bm...> - 2008-08-18 23:25:37
|
sqrt is usually faster than sin and cos both in floating point hardware and software. e.r. On Tue, 2008-08-19 at 01:16 +0200, Albert Graef wrote: > Eddie Rucker wrote: > > Sorry. > > > > sqrt (x+:y) = sqrt (0.5*(r+x)) +: sqrt (0.5*(r-x)) > > when > > r = sqrt x*x+y*y; > > end; > > That looks neat, I think I'm going to use that. :) > |
From: Eddie R. <er...@bm...> - 2008-08-18 23:27:45
|
On Mon, 2008-08-18 at 18:25 -0500, Eddie Rucker wrote: Dang! I keep forgetting to put parenthesis around the r = sqrt (x*x+y*y) e.r. > sqrt is usually faster than sin and cos both in floating point hardware > and software. > > e.r. > > On Tue, 2008-08-19 at 01:16 +0200, Albert Graef wrote: > > Eddie Rucker wrote: > > > Sorry. > > > > > > sqrt (x+:y) = sqrt (0.5*(r+x)) +: sqrt (0.5*(r-x)) > > > when > > > r = sqrt x*x+y*y; > > > end; > > > > That looks neat, I think I'm going to use that. :) > > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > pure-lang-users mailing list > pur...@li... > https://lists.sourceforge.net/lists/listinfo/pure-lang-users |
From: Ryan S. <rya...@us...> - 2008-08-18 23:33:37
Attachments:
prelude.log
pure-devel.txt
|
On Aug 18, 2008, at 07:08, Albert Graef wrote: > I'm basically through with my 0.5 TODO list now (Windows port > notwithstanding; I can hopefully take a look at that later today). > So if > anyone is still listening, it would be nice if you could take the > latest > svn for a test drive. ;-) Ok, I tested r534 on Mac OS X 10.5 Leopard. The install_name stuff is working, so I could remove my patch, thanks. The prelude test failed; the log is attached. The issue with the pass or fail being printed on the next line on Leopard hasn't been resolved yet. |
From: Albert G. <Dr....@t-...> - 2008-08-18 23:50:50
|
Ryan Schmidt wrote: > The prelude test failed; the log is attached. Probably not a big issue, given that all other tests pass. Could you please run the following: rm test/prelude.log && make logs Then please send me the newly created test/prelude.log so that I can figure out where it differs on your system. 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: Ryan S. <rya...@us...> - 2008-08-18 23:59:37
|
On Aug 18, 2008, at 18:51, Albert Graef wrote: > Ryan Schmidt wrote: >> The prelude test failed; the log is attached. > > Probably not a big issue, given that all other tests pass. > > Could you please run the following: > > rm test/prelude.log && make logs > > Then please send me the newly created test/prelude.log so that I can > figure out where it differs on your system. After running "rm test/prelude.log && make logs", "svn diff test" shows no differences. |
From: Albert G. <Dr....@t-...> - 2008-08-19 00:04:06
|
Ryan Schmidt wrote: > After running "rm test/prelude.log && make logs", "svn diff test" > shows no differences. Surely not, but I need your version of the file now to compare against my "golden" log. :) 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: Ryan S. <rya...@us...> - 2008-08-19 04:21:19
Attachments:
prelude.log
|
On Aug 18, 2008, at 19:05, Albert Graef wrote: > Ryan Schmidt wrote: >> After running "rm test/prelude.log && make logs", "svn diff test" >> shows no differences. > > Surely not, but I need your version of the file now to compare against > my "golden" log. :) Here it is, but it is the same prelude.log that is in your repository (hence no differences shown by "svn diff") |
From: Albert G. <Dr....@t-...> - 2008-08-19 05:58:27
|
Ryan Schmidt wrote: > Here it is, but it is the same prelude.log that is in your repository > (hence no differences shown by "svn diff") Sorry, it was late. ;-) But if regenerating the log doesn't show any differences, then it shouldn't fail on 'make check' either. Does it still fail there? Can you please send me the output of this command: DYLD_LIBRARY_PATH=. PURELIB=lib ./pure -n -v7 lib/prelude.pure | diff test/prelude.log - -- 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: Ryan S. <rya...@us...> - 2008-08-19 06:18:57
Attachments:
test017.log
|
On Aug 19, 2008, at 00:59, Albert Graef wrote: > Ryan Schmidt wrote: > >> Here it is, but it is the same prelude.log that is in your repository >> (hence no differences shown by "svn diff") > > Sorry, it was late. ;-) > > But if regenerating the log doesn't show any differences, then it > shouldn't fail on 'make check' either. Does it still fail there? > > Can you please send me the output of this command: > DYLD_LIBRARY_PATH=. PURELIB=lib ./pure -n -v7 lib/prelude.pure | diff > test/prelude.log - No output! Separately: I tested on Tiger. There, prelude.pure and all other tests pass, except test017.pure which fails. I deleted test017.log and ran "make logs", and test017.log is different; attached. |