Brainfuck interpreter stack overflow

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Brainfuck interpreter stack overflow

Edgar Klerks-2
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100128/1a65a70b/attachment.html
Reply | Threaded
Open this post in threaded view
|

Reversing the lines read from stdin

Tim Perry-2

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100128/9659ac7b/attachment.html
Reply | Threaded
Open this post in threaded view
|

Reversing the lines read from stdin

Rahul Kapoor
> 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)
Reply | Threaded
Open this post in threaded view
|

Reversing the lines read from stdin

Krzysztof Skrzętnicki
In reply to this post by Tim Perry-2
On Thu, Jan 28, 2010 at 21:44, Tim Perry <[hidden email]> wrote:

>
> 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
Reply | Threaded
Open this post in threaded view
|

Reversing the lines read from stdin

Daniel Fischer-4
In reply to this post by Tim Perry-2
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?