code wiki / _hdl_build / nx_cascade.nx
nx_cascade.nx source
↩ module page · 17 lines · 1366 B
1// nx_cascade.nx -- LIB: the EVOLVING second-life CASCADE marketplace. When a part is replaced with a better one (the
2// evolving regime), it still has remaining life -- instead of scrapping it, it CASCADES down tiers (wealthy / data
3// center -> middle class -> poor / schools / non-profits) with government help. Each tier uses the remaining life, pays
4// a declining price (the bottom free, gov+non-profit subsidized), so the FULL life is used (near-zero waste) and the
5// per-year hardware/energy cost DECLINES as it cascades, while the top tier keeps upgrading -- a win-win-win. (The
6// solar-panel roof-cascade idea: the wealthy pass down to the middle pass down to the poor.) never-brick #26: pure
7// arithmetic, deterministic. license_tier: ORIGINAL
8import "nx_syscalls.nx"
9
10// total life-years used across all tiers.
11func casc_total_years(years: *i64, n: i64) -> i64 { var s: i64=0; var i: i64=0; while i<n { s=s+years[i]; i=i+1 } return s }
12
13// life utilization in permil = used / full-life (cascade uses the whole life; scrap-after-tier-0 wastes the rest).
14func casc_util_permil(used: i64, full: i64) -> i64 { if full<=0 { return 0 } return used*1000/full }
15
16// per-year cost for a tier = price / years (declines down the cascade; the bottom tier -> 0).
17func casc_annual_cost(price: i64, years: i64) -> i64 { if years<=0 { return 0 } return price/years }