Programming performance/JN K

From HaskellWiki
< Programming performance
Revision as of 18:04, 9 March 2007 by Jn (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Submission in K. Start to finish time: 17 minutes.
RaymondH showed me his, so this might not be entirely originial.
I tried not to look at any of the K solutions.

/ parse quotes
D:|1_*("    F  ";" ")0:`:/tmp/gspc.txt

/ Cash and Portfolio (price -> quantity)
C:10000.00; P:(`u#0#0.)!0#0.

/ Trading strategy
T:{if[~.97<x%y; P[x]+:(b:C%10)%x; C-:b]; C+:x*+/P p:p@&~1.06>x%p:!P; P[p]:0.}

/ run strategy on each pair (current and previous) of prices

/ Sell off remaining