Created
April 28, 2010 18:56
-
-
Save tav/382546 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
currencies: [GBP USD EUR NOK] | |
cache: [] | |
<input id: amount value:: 0 /> | |
<input id: from value:: USD /> | |
<input id: to value:: GBP /> | |
<div> | |
if $from/value not in $currencies or $to/value not in $currencies | |
<span class: error>"Sorry, unknown currency symbol"</span> | |
else | |
if [$from/value $to/value] not in cache | |
cache[$from/value $to/value]: get-remote-exchange-rate $from/value $to/value | |
try | |
amount-as-number: to-number $amount/value | |
<span>$amount/value $from/value "=" (cache[$from/value $to/value] * amount-as-number) $to/value</span> | |
catch | |
<span>"Sorry, the value is not a number"</span> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment