[Haskell-cafe] How to solve this problem?It's quite easy in PHP.
Donald Bruce Stewart
dons at cse.unsw.edu.au
Tue Feb 13 20:41:25 EST 2007
keepbal:
>
> For example,
> -----------------------------------
> <?php
> //test.php
> require ("tiny.php");//Tiny is a small template engine.
> $tn=new Tiny();
> $arr=new Array();
> $arr['a']='1';
> $arr['b']='2';
> $arr['c']='3';
> $tn->set('arr',$arr);
> $tn->show('_test.php');
> ?>
> -----------------------------------
> <?php require('_header.php');?>
> <?php
> foreach($arr as $key => $val){
> echo "$key = $val <br>";
> }
> ?>
> <?php require('_footer.php');?>
> -----------------------------------
> a = 1
> b = 2
> c = 3
> -----------------------------------
Doesn't look that easy. I guess its not too bad though.
Anyway, here's Data.Map for you:
import Data.Map
import Text.Printf
m = fromList (zip "abc" [1..])
main = mapM_ draw (toList m)
draw (k,v) = printf "%c = %d\n" k (v :: Int)
And if you want to run this:
$ runhaskell A.hs
a = 1
b = 2
c = 3
More information about the Haskell-Cafe
mailing list