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:[EMAIL PROTECTED]

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to