Brandon Allbery wrote:
case () of
() | s == reverse s - putStrLn palindrome
_ - putStrLn nope
Tom Murphy wrote:
This is kind of a hack of case, though. I think what the OP was looking
for is
isPalindrome word
| (word == reverse word) = putStrLn (word ++ is a
To clarify, by hack I meant that it seemed like a workaround specifically
to keep case in the OP's code, when it seemed like they were looking for
the functionality of guards.
amindfv / Tom
On Dec 11, 2011 1:39 PM, Yitzchak Gale g...@sefer.org wrote:
Brandon Allbery wrote:
case () of
()
Why do you people hate 'if' statements?
2011/12/9 Brandon Allbery allber...@gmail.com
On Thu, Dec 8, 2011 at 15:52, Tom Murphy amin...@gmail.com wrote:
On Wed, Dec 7, 2011 at 11:46 PM, Brandon Allbery allber...@gmail.comwrote:
case () of
() | s == reverse s - putStrLn palindrome
_
On Fri, Dec 9, 2011 at 04:16, Yves Parès limestr...@gmail.com wrote:
Why do you people hate 'if' statements?
It's more that the language spec does; if statements, along with a number
of other things, desugar to case which is the fundamental conditional
construct.
(And more personally, I find
I agree with all that, but in *this *special case, I think that
case something of
True -
False -
is less nice and obvious than
if something
then
else
2011/12/9 Brandon Allbery allber...@gmail.com
On Fri, Dec 9, 2011 at 04:16, Yves Parès limestr...@gmail.com
On Fri, Dec 9, 2011 at 05:16, Yves Parès limestr...@gmail.com wrote:
I agree with all that, but in *this *special case, I think that
I should also note that the OP mentioned using if, but was
surprised/confused by the behavior of case, which is why that's what we've
been focusing on.
--
Alexej The interesting thing is, that if I change the case ... of
Alexej statement to an if ... then ... else statement, this magically
Alexej starts to work. Since I no longer am enrolled (I have to take
Alexej the course next year), I can't ask a teacher, but my curiosity
Alexej still bugs me.
On Wed, Dec 7, 2011 at 11:46 PM, Brandon Allbery allber...@gmail.comwrote:
On Wed, Dec 7, 2011 at 23:24, Alexej Segeda aloscha_den_st...@hotmail.com
wrote:
case s of
(s == reverse s)- putStrLn (s ++ is a
palindrome)
otherwise
On Thu, Dec 8, 2011 at 15:52, Tom Murphy amin...@gmail.com wrote:
On Wed, Dec 7, 2011 at 11:46 PM, Brandon Allbery allber...@gmail.comwrote:
case () of
() | s == reverse s - putStrLn palindrome
_ - putStrLn nope
This is kind of a hack of case, though. I think
Hi!
A couple of months ago, I wrote an exam in an introductory Haskell course and
failed, all because of an assignment that I was convinced would work, but for
some reason, it didn't. The assignment was to write a function that would take
a line, then determine whether it's a palindrome or
On Wed, Dec 7, 2011 at 23:24, Alexej Segeda
aloscha_den_st...@hotmail.comwrote:
case s of
(s == reverse s)- putStrLn (s ++ is a
palindrome)
otherwise - putStrLn (s ++ is not a
palindrome)
case does pattern matching, not
colour_grid :: (Particle - IO ()) - Grid ph - IO ()
colour_grid fn g = sequence_ $ runST $ do
ps - grid_coords g
mapM
(\pix - do
particle - read_grid g pix
return $ fn particle
)
ps
When I attempt to run this, GHCi just gives me a very cryptic type
checker error. I can't
I haven't tried to run the code, but my first bet is that, due to the
rank-2 polymorphism of ST, you should use parenthesis instead of $ in
the case of runST.
On Sun, Aug 24, 2008 at 3:25 PM, Andrew Coppin
[EMAIL PROTECTED] wrote:
colour_grid :: (Particle - IO ()) - Grid ph - IO ()
colour_grid
Alfonso Acosta wrote:
I haven't tried to run the code, but my first bet is that, due to the
rank-2 polymorphism of ST, you should use parenthesis instead of $ in
the case of runST.
Perhaps if Andrew is using an old compiler.
That is no longer a problem in recent versions of GHC.
A more basic
Am Sonntag, 24. August 2008 17:21 schrieb Yitzchak Gale:
Alfonso Acosta wrote:
I haven't tried to run the code, but my first bet is that, due to the
rank-2 polymorphism of ST, you should use parenthesis instead of $ in
the case of runST.
Perhaps if Andrew is using an old compiler.
That
BTW, this is a case where it may be more convenient to use forM:
forM ps $ \pix - do
particle - read_grid g pix
return $ fn particle
(untested...)
forM is just another way of saying (flip mapM).
/ Emil
Andrew Coppin skrev:
colour_grid :: (Particle - IO ()) - Grid ph - IO ()
I wrote:
A more basic issue is that fn is in the IO monad,
but its use inside the mapM will need it to be in the ST
monad.
Daniel Fischer wrote:
No,
return (fn particle) :: ST s (IO ())
, so that's fine.
Ah, true. But I doubt that Andrew really meant to
do the calculation in ST s (IO ()).
Am Montag, 25. April 2005 08:16 schrieb Michael Vanier:
I've been trying to generate an infinite list of random coin flips in GHC
6.4, and I've come across some strange behavior:
--
import System.Random
data Coin = H | T
On Sun, 2005-04-24 at 23:16 -0700, Michael Vanier wrote:
I've been trying to generate an infinite list of random coin flips in GHC
6.4, and I've come across some strange behavior:
--
import System.Random
data Coin = H | T
19 matches
Mail list logo