Last active
July 28, 2020 16:01
-
-
Save rudolph9/bb87e8205353dd2ff28d3d080dc70992 to your computer and use it in GitHub Desktop.
Currency conversion
This file contains hidden or 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
// cue v0.3.0-alpha1 | |
given: { | |
INC: USD: v: 2.0 | |
USD: GBP: v: 3.0 | |
} | |
_hydrated: given & { | |
for k, v in given | |
for _, v1 in given | |
for k2, _ in v1 { | |
"\(k)": "\(k)": v: 1.0 | |
"\(k2)": "\(k2)": v: 1.0 | |
"\(k)": "\(k2)": v: number | |
"\(k2)": "\(k)": v: number | |
} | |
} | |
_keys: [ for k,_ in _hydrated { k } ] | |
fromToRate: _hydrated & { | |
[a=_]: { | |
[b=(!=a)]: { | |
for k in _keys if a != k && b != k { | |
v: fromToRate[a][k].v * fromToRate[k][b].v | |
} | |
} | |
} | |
} |
Author
rudolph9
commented
Jul 28, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment