Skip to content

Instantly share code, notes, and snippets.

@tav
Created April 28, 2010 18:56
Show Gist options
  • Save tav/382546 to your computer and use it in GitHub Desktop.
Save tav/382546 to your computer and use it in GitHub Desktop.
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