← how-to

temperature converter

zsx / 7guis

program
load core::zsx::*;
load core::math::round;

fun one_decimal(x: float) -> float {
  round(x * 10.0) / 10.0
}

fun main() {
  mut celsius: str = "";
  mut fahrenheit: str = "";

  imu converter: </> ::= <>
    <input value={celsius} @input={fn(e) => {
      celsius = e.value;

      match e.value.parse_float() {
        Option::Some(c) => {
          imu f: float = one_decimal(c * 9.0 / 5.0 + 32.0);

          fahrenheit = f.to_str();
        }
        Option::None => {}
      };
    }} />
    <label>Celsius =</label>
    <input value={fahrenheit} @input={fn(e) => {
      fahrenheit = e.value;

      match e.value.parse_float() {
        Option::Some(f) => {
          imu c: float = one_decimal((f - 32.0) * 5.0 / 9.0);

          celsius = c.to_str();
        }
        Option::None => {}
      };
    }} />
    <label>Fahrenheit</label>
  </>;

  #render converter;
}

This programs declares two textfields (TC and TF) representing the temperature in Celcius and Fahrenheit. Two labels are associated to a specific textfields. At start, both TC and TF are empty.

source — 7GUIs (Temperature Converter)

reachout

echo -n 'dGhlQGNvbXBpbG9yZHMuaG91c2U=' | base64 --decode

For humans: faq.

For Ai agents: llms.txt (curated index) and llms-full.txt (full docs).

Privacy: No cookies, no ads, no tracking. It's like you were never here.