Re: [q-lang-users] composing or lambda?
Brought to you by:
agraef
From: Eddie R. <ed...@bm...> - 2006-11-10 17:22:26
|
Eddie Rucker, Addendum (add this to the readability/performance question): I also just discovered I don't need variables (although I saw something like this somewhere in the docs): addSurvey = zipwith (zipwith (+)); addSurveyId = map (mklist 0 . (#)); > I've go two lines in a program that computes stats on a file of surveys: > > addSurvey X Y = zipwith (zipwith (+)) X Y; > addSurveyId A = map Id A where Id = (mklist 0) . (#); > > where X and Y are two lists with a 1 in the position of the student > response, like [0,0,1,0,0], and each survey is a list of these lists. > > My question is: > Does the "where" in addSurveyId compute "(mklist 0) . (#)" once and use > the new function throughout the map operation? Or does map just put > "(mklist 0) .(#)" in front of each element in the list and then reduce? > > Second question: > Which is better, readability and/or performance wise? > > "addSurveyId A = map (\X. mklist 0 (#X) A;" > > or > > "addSurveyId A = map ZeroVec A where ZeroVec = (mklist 0) . (#);" > > or > > "addSurveyId A = map (mklist 0 .(#)) A;" > > Eddie > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > q-lang-users mailing list > q-l...@li... > https://lists.sourceforge.net/lists/listinfo/q-lang-users > |