On 1/19/07, Sebastian Sylvan <[EMAIL PROTECTED]> wrote:
On 1/19/07, Sebastian Sylvan <[EMAIL PROTECTED]> wrote:
> On 1/19/07, Fernan Bolando <[EMAIL PROTECTED]> wrote:
> > hi all
> >
> > Since I am very new to haskell and still learning, I hope I will not
> > annoy poeple by asking the following question.
> >
> > what is the simplest way to implement the following code in haskell?
> > it's just printing the
> > contents of 2D array.
> >
> > for(i = 0; i < imax; i++){
> >         for(n = 0; n < nmax; n++){
> >                 printf("%i:%i = %f\n", array[i][n]);
> >         }
> > }
>
> Do you mean:
>
> > for(i = 0; i < imax; i++){
> >         for(n = 0; n < nmax; n++){
> >                 printf("%i:%i = %f\n", i,n,array[i][n]);
> >         }
> > }
>
> If so, how about:
>
> sequence [ putStr (show i ++ ":" ++ show n ++ " = " show arr!(i,n) |
> (i,n) <- indices arr ]
>

Sorry:
sequence [ putStrLn (show i ++ ":" ++ show n ++ " = " show arr!(i,n))
| (i,n) <- indices arr ]


Bah, it's way to early, forgot another parenthesis:
sequence [ putStrLn (show i ++ ":" ++ show n ++ " = " show (arr!(i,n)) )
               | (i,n) <- indices arr ]


--
Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to