POV-Ray : Newsgroups : povray.off-topic : My first C++ program : Re: (And in Haskell. Obviously.) Server Time
1 Oct 2024 09:27:12 EDT (-0400)
  Re: (And in Haskell. Obviously.)  
From: Slime
Date: 20 Sep 2008 16:11:31
Message: <48d558f3$1@news.povray.org>
> To me, all that tricky slight of hand with "break" and "continue" seems 
> far less clear then just directly saying exactly what you want to happen, 
> as the Haskell version does.

You can eliminate the "continue" in your example if you write it like this:

    if ( cmd == "^" )
        break;
    else if ( cmd == "+" )
        Add(stack);
    else if ( cmd == "-" )
        Sub(stack);
    else
        stack.push_back(1);


As for the break, it could just as easily be a 'return' like in the haskell 
code, if you didn't want to print "exit" or if you brought the loop into its 
own function.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.