How would you replace a field in a CSV file?

Hi Pete. For such a small self-contained task, I don't think Haskell is any better than Python. Haskell would come into its own if you wanted some assurance about type safety, and/or were taking on a task large enough to warrant the use of records (and hence record update notation). Regards, Tom

tpledger@ihug.co.nz writes:
For such a small self-contained task, I don't think Haskell is any better than Python.
I figured as much, but I thought with the new FPS lazy bytestrings it might have a chance in terms of raw speed. On the other side of the coin, in terms of elegance, I thought I'd ask as haskellers always amaze me with their one-liners :-)

Hello tpledger, Monday, October 2, 2006, 3:11:29 AM, you wrote:
For such a small self-contained task, I don't think Haskell is any better than Python.
i disagree. while it's hard to beat Python version in number of lines, Haskell version may have the same length and better performance. for this particular task, using list as intermediate datastructure make program both long and inefficient. if ByteString will include array-based splitting and joining, the things will become much better main = B.interact $ B.unlines . map doline . B.lines where doline = B.joinArray comma . mapElem 9 fixup . B.splitArray ',' fixup s = M.findWithDefault s s comma = B.pack "," mapElem n func arr = arr//[(n,func (arr!n))] if mapElem, splitArray, joinArray will be library functions (i think they are good candidates) this program will be not longer than Python one -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (3)
-
Bulat Ziganshin
-
Pete Kazmier
-
tpledger@ihug.co.nz