[q-lang-users] composing or lambda?
Brought to you by:
agraef
From: Eddie R. <ed...@bm...> - 2006-11-10 17:16:41
|
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 |