<div dir="ltr">You can do something like<div><br></div><div><font face="monospace, monospace"> fibTable n = [ show x ++ "\t" ++ show y | (x,y) <- zip [1..] (fibs n) ]</font></div><div><font face="monospace, monospace"> where</font></div><div><font face="monospace, monospace"> fibs n = list containing fibonacci numbers from fib(1) to fib(n)</font></div><div><font face="monospace, monospace"><br></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 11 November 2015 at 18:57, Roelof Wobben <span dir="ltr"><<a href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div>Op 11-11-2015 om 14:11 schreef Sumit
Sahrawat, Maths & Computing, IIT (BHU):<br>
</div><span class="">
<blockquote type="cite">
<div dir="ltr">Hint 1) fib n = fib (n - 1) + fib (n - 2), with
proper base cases
<div><br>
</div>
</div>
</blockquote>
<br></span>
oke, so use recursion. No problem. <br><span class="">
<br>
<blockquote type="cite">
<div dir="ltr">
<div>Hint 2) use mapM_ to print a list of pairs, where the list
is created by zipping [1..] with the list of fibonacci numbers</div>
</div>
<div class="gmail_extra"><br>
</div>
</blockquote>
<br></span>
mapM_ is not explained in the first 5 chapters of Craft of
functional programming,<br>
<br>
Can not both or one of the two be done with list comprehension
because all former exercises uses list comprehension <br>
<br>
Roelof<br>
<br>
<br>
<blockquote type="cite"><div><div class="h5">
<div class="gmail_extra">
<div class="gmail_quote">On 11 November 2015 at 18:29, Roelof
Wobben <span dir="ltr"><<a href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I have this exercise :<br>
<br>
Define a function<br>
fibTable :: Integer -> String<br>
which produces a table of Fibonacci numbers. For instance,
the effect of putStr<br>
(fibTable 6) should be<br>
n fib n<br>
0 0<br>
1 1<br>
2 1<br>
3 2<br>
4 3<br>
5 5<br>
6 8<br>
<br>
<br>
<br>
1) Can somone give me any pointers how to calculate the fibb
numbers with list comprehension.<br>
I know that the fib numbers are (n -1) + n<br>
<br>
2) Can someone give me any pointers how to write the outcome
of every run<br>
<br>
Roelof<br>
<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div>Regards</div>
<div dir="ltr">
<div><br>
</div>
<div>Sumit Sahrawat</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
Beginners mailing list
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
<br>
<fieldset></fieldset>
<br>
</div></div><p color="#000000" align="left">Geen virus
gevonden in dit bericht.<br>
Gecontroleerd door AVG - <a href="http://www.avg.com" target="_blank">www.avg.com</a><br>
Versie: 2015.0.6176 / Virusdatabase: 4460/10979 - datum van
uitgifte: 11/11/15</p>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Regards</div><div dir="ltr"><div><br></div><div>Sumit Sahrawat</div></div></div></div></div></div></div>
</div>