Difference between revisions of "User:Ashley Y"

From HaskellWiki
Jump to navigation Jump to search
Line 15: Line 15:
   
 
<haskell>
 
<haskell>
  +
{-
foo :: (Monad m) -> m Int
 
  +
My program
foo = x where
 
  +
-}
  +
  +
import Foreign.C
  +
 
foo :: (Monad m) -> m (Int,Int)
 
foo = (x-2,x + 1) where
 
x = 3
 
x = 3
   
Line 23: Line 29:
 
main = do
 
main = do
 
a <- foo
 
a <- foo
putStr ("And the answer is: " ++(show foo)++"\n")
+
putStr ("And the answer is: " ++(show (fst a))++"\n")
 
</haskell>
 
</haskell>

Revision as of 20:35, 7 March 2006

Ashley Yakeley

I hereby license all my contributions to this wiki under the simple permissive license on HaskellWiki:Copyrights. —Ashley Y 05:25, 14 January 2006 (UTC)

GeSHi Tests

C

<c> for (int a=0;a<3;a++)

 printf ("%d\n",a);

</c>

Haskell

{-
My program
-}

import Foreign.C

foo :: (Monad m) -> m (Int,Int)
foo = (x-2,x + 1) where
  x = 3

-- The main function
main :: IO ()
main = do
  a <- foo
  putStr ("And the answer is: " ++(show (fst a))++"\n")