diff options
author | Eduardo Julian | 2020-12-02 20:37:13 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-12-02 20:37:13 -0400 |
commit | 28c724857d76afdc40b5b036f415cc151eb66263 (patch) | |
tree | 3e970ca2a10dd7bb5c7ddd405349762945464d39 /stdlib/source/lux/tool | |
parent | 34e310622bdeb1d0588c0664c0e78cbaa84f837c (diff) |
Replaced "contains?" function with "key?" function.
Diffstat (limited to 'stdlib/source/lux/tool')
-rw-r--r-- | stdlib/source/lux/tool/compiler/version.lux | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/stdlib/source/lux/tool/compiler/version.lux b/stdlib/source/lux/tool/compiler/version.lux index 3965b9b28..df405e75d 100644 --- a/stdlib/source/lux/tool/compiler/version.lux +++ b/stdlib/source/lux/tool/compiler/version.lux @@ -1,5 +1,50 @@ (.module: - [lux #*]) + [lux #* + [data + [number + ["n" nat]] + [text + ["%" format]]]]) (type: #export Version Nat) + +(def: range 100) + +(def: level + (n.% ..range)) + +(def: current + (-> Nat Nat) + (|>>)) + +(def: next + (n./ ..range)) + +(def: #export patch + (-> Version Nat) + (|>> ..current ..level)) + +(def: #export minor + (-> Version Nat) + (|>> ..next ..level)) + +(def: #export major + (-> Version Nat) + (|>> ..next ..next ..level)) + +(def: separator ".") + +(def: (padded value) + (-> Nat Text) + (if (n.< 10 value) + (%.format "0" (%.nat value)) + (%.nat value))) + +(def: #export (format version) + (%.Format Version) + (%.format (..padded (..major version)) + ..separator + (..padded (..minor version)) + ..separator + (..padded (..patch version)))) |