https://wiki.haskell.org/index.php?title=Programming_performance/Magnus_Haskell&feed=atom&action=history
Programming performance/Magnus Haskell - Revision history
2024-03-28T16:22:47Z
Revision history for this page on the wiki
MediaWiki 1.35.5
https://wiki.haskell.org/index.php?title=Programming_performance/Magnus_Haskell&diff=11812&oldid=prev
Newsham: mention minor bugs
2007-03-07T17:53:08Z
<p>mention minor bugs</p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 17:53, 7 March 2007</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 39:</td>
<td colspan="2" class="diff-lineno">Line 39:</td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> print result</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> print result</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></haskell></div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div></haskell></div></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td colspan="2" class="diff-empty"> </td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>'''Bugs''': Two minor bugs here. Purchases are made at ''lastPrice'' rather than ''todayPrice''. The wrong column of the data is used. It should be the last column not the 4th column. [[User:Newsham|Newsham]] 17:53, 7 March 2007 (UTC)</div></td>
</tr>
</table>
Newsham
https://wiki.haskell.org/index.php?title=Programming_performance/Magnus_Haskell&diff=11792&oldid=prev
Magnus at 05:04, 7 March 2007
2007-03-07T05:04:51Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 05:04, 7 March 2007</td>
</tr><tr>
<td colspan="2" class="diff-lineno">Line 2:</td>
<td colspan="2" class="diff-lineno">Line 2:</td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''Skill''': Intermediate. I'm self taught in Haskell and use it as a hobbyist but haven't used it much for serious work.</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''Skill''': Intermediate. I'm self taught in Haskell and use it as a hobbyist but haven't used it much for serious work.</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''Time''': 25 minutes.</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>* '''Time''': 25 minutes.</div></td>
</tr>
<tr>
<td class="diff-marker">−</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>* '''Notes''': 10 minutes spent on a silly bug where I had typed 1 instead of 100. This code is not very pretty but it works.</div></td>
<td class="diff-marker">+</td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>* '''Notes''': 10 minutes spent on a silly bug where I had typed 1 instead of 100. This code is not very pretty but it works<ins class="diffchange diffchange-inline">. A while after submitting I noticed I used the wrong data column. It should say column 4, not 3 in closingPrice</ins>.</div></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td>
</tr>
<tr>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Code ==</div></td>
<td class="diff-marker"> </td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>== Code ==</div></td>
</tr>
</table>
Magnus
https://wiki.haskell.org/index.php?title=Programming_performance/Magnus_Haskell&diff=11791&oldid=prev
Magnus at 04:51, 7 March 2007
2007-03-07T04:51:32Z
<p></p>
<p><b>New page</b></p><div>* '''Language''': Haskell<br />
* '''Skill''': Intermediate. I'm self taught in Haskell and use it as a hobbyist but haven't used it much for serious work.<br />
* '''Time''': 25 minutes.<br />
* '''Notes''': 10 minutes spent on a silly bug where I had typed 1 instead of 100. This code is not very pretty but it works.<br />
<br />
== Code ==<br />
<haskell><br />
import Data.List (partition,foldl')<br />
<br />
closingPrice::String->Double<br />
closingPrice line =<br />
read (words line !! 3)<br />
<br />
sell assets price = sum (map (\(_,shares)->shares*price) assets)<br />
<br />
tradeOnce (cash,assets,lastPrice) todayPrice =<br />
if todayPrice <= lastPrice * 97/100 then<br />
let buyCost = cash*10/100 in<br />
(cash-buyCost, (lastPrice,buyCost/lastPrice):assets, todayPrice)<br />
else let (toSell,toKeep) =<br />
partition (\(buyPrice,_)->todayPrice >= buyPrice*106/100) assets<br />
in (cash + sell toSell todayPrice,<br />
toKeep,<br />
todayPrice)<br />
<br />
notComment ('#':rest) = False<br />
notComment _ = True<br />
<br />
trade input =<br />
let (firstPrice:restPrices) = reverse $<br />
map closingPrice $<br />
filter notComment $<br />
lines input<br />
in foldl' tradeOnce (10000.0,[],firstPrice) restPrices<br />
<br />
main = do input <- readFile "gspc.txt"<br />
let (cash,toSell,lastPrice) = trade input<br />
let result = cash + sell toSell lastPrice<br />
print result<br />
</haskell></div>
Magnus