Re: [q-lang-users] Vector module
Brought to you by:
agraef
From: <ed...@ri...> - 2007-10-02 17:40:55
|
<p>For RC1: are you going to have a msi to install on Windows or strictly c= vs?</p><p>I would like to see if one of my ODBC scripts on the Windows box = works correctly after the new Q updates. I cannot test this on Linux for va= rious reasons.<br /></p><p>Eddie </p><p><br /><strong>On Tue Oct 2 11= :28 , Albert Graef sent:<br /><br /></strong><blockquote style=3D"border-l= eft: 2px solid rgb(245, 245, 245); margin-left: 5px; margin-right: 0px; pad= ding-left: 5px; padding-right: 0px;">Albert Graef wrote:<br />=0D > So then the entire thing would boil down to providing the creation and= <br />=0D > type-checking convenience functions, as well as implementing the three= <br />=0D > operations 'get', 'put' and 'putmap' (or whatever we call them) on<br = />=0D > containers, and add some convenient syntactic sugar, which could easil= y<br />=0D > be done in an afternoon, I guess.<br />=0D <br />=0D All right, I have this implemented for reference tuples, lists and<br />=0D streams now. You can find the source here:<br />=0D <a target=3D"_blank" href=3D"../parse.pl?redirect=3Dhttp%3A%2F%2Fq-lang.cvs= .sourceforge.net%2Fq-lang%2Fq%2Fstdlib%2Freftypes.q%3Fview%3Dlog">http://q-= lang.cvs.sourceforge.net/q-lang/q/stdlib/reftypes.q\?view=3Dlog</a><br />= =0D <br />=0D Here are a few examples to show how this all works:<br />=0D <br />=0D =3D=3D> import reftypes // needs to be imported explicitly<br = />=0D <br />=0D =3D=3D> def Xs =3D reflist [1..10] // create a new reference list<br />= =0D <br />=0D =3D=3D> get (Xs!5) // get a member<br />=0D 6<br />=0D <br />=0D =3D=3D> Xs!!5 // syntactic sugar for the above<br />= =0D 6<br />=0D <br />=0D =3D=3D> put (Xs!5) 77 // change a member<br />=0D ()<br />=0D <br />=0D =3D=3D> Xs!5 :=3D 77 // syntactic sugar for the above<br = />=0D ()<br />=0D <br />=0D =3D=3D> Xs!!5<br />=0D 77<br />=0D <br />=0D =3D=3D> get Xs // get all members<br />=0D [1,2,3,4,5,77,7,8,9,10]<br />=0D <br />=0D =3D=3D> putmap (*2) Xs // destructive map<br />=0D ()<br />=0D <br />=0D =3D=3D> get Xs<br />=0D [2,4,6,8,10,154,14,16,18,20]<br />=0D <br />=0D =3D=3D> fill Xs 0 // fill with given value<br />=0D ()<br />=0D <br />=0D =3D=3D> get Xs<br />=0D [0,0,0,0,0,0,0,0,0,0]<br />=0D <br />=0D =3D=3D> Xs :=3D [1..10] // update all values at once<br />= =0D ()<br />=0D <br />=0D =3D=3D> get Xs<br />=0D [1,2,3,4,5,6,7,8,9,10]<br />=0D <br />=0D Tuples and streams work in an analogous fashion. (If you look at the<br />= =0D script, you will notice that reference streams are always memoized, so<br /= >=0D that they properly remember their reference values.) Infinite streams<br />= =0D work, too, provided that you don't try to apply the strict fill, put and<br= />=0D putmap operations to the entire stream -- a finite subsection of the<br />= =0D stream works, though:<br />=0D <br />=0D =3D=3D> def Xs =3D refstream {1..}<br />=0D <br />=0D =3D=3D> Xs!!5<br />=0D 6<br />=0D <br />=0D =3D=3D> Xs!5 :=3D 77<br />=0D ()<br />=0D <br />=0D =3D=3D> Xs!!5<br />=0D 77<br />=0D <br />=0D =3D=3D> def Ys =3D take 10 Xs // apply putmap only to this finite subse= quence<br />=0D <br />=0D =3D=3D> strict $ get Ys<br />=0D {1,2,3,4,5,77,7,8,9,10}<br />=0D <br />=0D =3D=3D> putmap (*2) Ys<br />=0D ()<br />=0D <br />=0D =3D=3D> strict $ get Ys<br />=0D {2,4,6,8,10,154,14,16,18,20}<br />=0D <br />=0D =3D=3D> Xs!!5<br />=0D 154<br />=0D <br />=0D Note that at this point only the first 10 members of the stream have<br />= =0D actually been evaluated, the rest of the stream is still ``thunked'':<br />= =0D <br />=0D =3D=3D> Xs<br />=0D {,,,,,,,,<br />=0D ,,ref 11|lazy (map ref (iterate (+1) ((+1) 11)))}<br />=0D <br />=0D <br />=0D John, is that what you wanted (more or less)? Any comments?<br />=0D <br />=0D Ok, I'm ready to do a first release candidate now. Any last-minute bug<br /= >=0D reports? :)<br />=0D <br />=0D Cheers,<br />=0D Albert<br />=0D <br />=0D -- <br />=0D Dr. Albert Gr"af<br />=0D Dept. of Music-Informatics, University of Mainz, Germany<br />=0D Email: <a href=3D"javascript:top.opencompose('Dr....@t-...','','',= '')">Dr....@t-...</a>, <a href=3D"javascript:top.opencompose('ag@mu= wiinfa.geschichte.uni-mainz.de','','','')">ag...@mu...schichte.uni-mainz= .de</a><br />=0D WWW: <a target=3D"_blank" href=3D"../parse.pl?redirect=3Dhttp%3A%2F%2Fww= w.musikinformatik.uni-mainz.de%2Fag">http://www.musikinformatik.uni-mainz.d= e/ag</a><br />=0D <br />=0D -------------------------------------------------------------------------<b= r />=0D This SF.net email is sponsored by: Microsoft<br />=0D Defy all challenges. Microsoft(R) Visual Studio 2005.<br />=0D <a target=3D"_blank" href=3D"../parse.pl?redirect=3Dhttp%3A%2F%2Fclk.atdmt.= com%2FMRT%2Fgo%2Fvse0120000070mrt%2Fdirect%2F01%2F">http://clk.atdmt.com/MR= T/go/vse0120000070mrt/direct/01/</a><br />=0D _______________________________________________<br />=0D q-lang-users mailing list<br />=0D <a href=3D"javascript:top.opencompose('q-l...@li...',= '','','')">q-l...@li...</a><br />=0D <a target=3D"_blank" href=3D"../parse.pl?redirect=3Dhttps%3A%2F%2Flists.sou= rceforge.net%2Flists%2Flistinfo%2Fq-lang-users">https://lists.sourceforge.n= et/lists/listinfo/q-lang-users</a><br />=0D </blockquote>=0D </p><BR>= |