Re: [Haskell-beginners] Brainfuck interpreter stack overflow

He Felipe, I think you are right. Now I essentially have 2 data tapes, while I wanted a grid. The results of up and down are independent of left and right. I have to redesign it again. With kind regards, Edgar

I wrote a simple program: it reads the contents from standard in and reverses the order of the lines. I imagine there are many cleaner ways to do this. Anybody willing to post some rewrites? Thanks, Tim main = interact reverseFile reverseFile s = unlines $ lines $ foldr combineStr [] (lines s) combineStr s1 s2 = s2 ++ "\n" ++ s1

Anybody willing to post some rewrites? main = interact reverseFile reverseFile s = unlines $ lines $ foldr combineStr [] (lines s) combineStr s1 s2 = s2 ++ "\n" ++
I personally find the point-free version easier to read.. reverseFile = unlines . lines . foldr combineStr [] . lines Vs reverseFile s = unlines $ lines $ foldr combineStr [] (lines s)

Am Donnerstag 28 Januar 2010 21:44:04 schrieb Tim Perry:
I wrote a simple program: it reads the contents from standard in and reverses the order of the lines. I imagine there are many cleaner ways to do this. Anybody willing to post some rewrites?
Thanks, Tim
main = interact reverseFile reverseFile s = unlines $ lines $ foldr combineStr [] (lines s) combineStr s1 s2 = s2 ++ "\n" ++ s1
main = interact (unlines . reverse . lines) perhaps?

On Thu, Jan 28, 2010 at 21:44, Tim Perry
I wrote a simple program: it reads the contents from standard in and reverses the order of the lines. I imagine there are many cleaner ways to do this. Anybody willing to post some rewrites?
Thanks, Tim
main = interact reverseFile reverseFile s = unlines $ lines $ foldr combineStr [] (lines s) combineStr s1 s2 = s2 ++ "\n" ++ s1
What about this version: main = interact (unlines . reverse . lines) Best regards Krzysztof Skrzętnicki
participants (5)
-
Daniel Fischer
-
Edgar Klerks
-
Krzysztof Skrzętnicki
-
Rahul Kapoor
-
Tim Perry