hello.km 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. do { os::println 'Hello World' }
  2. . { then { os::println { "[OS Info] system=?, arch=? (?)"
  3. let { system, arch, is-64-bit } := os::PlatformInfo,
  4. (system, arch, (if is-64-bit: '64-bit', else: '32-bit')) } } }
  5. . { then { os::println 'timer' } }
  6. . { then { wait { timeout: 2000 } } }
  7. . { then { os::println { String { exp { log { Complex (5.0, 5.0) } } } } } }
  8. . { then { os::println (2.0 * { Complex (0.0, 1.0) }).{sqrt}.{asin}.{sin}.{String} } }
  9. . { then { os::println (2.0 * { Complex (0.0, 1.0) }).{sqrt}.{acos}.{cos}.{String} } }
  10. . { then { os::println (2.0 * { Complex (0.0, 1.0) }).{sqrt}.{atan}.{tan}.{String} } }
  11. . { then { os::println { String (20.[Integer] ** 11) } } }
  12. . { then { os::println { String { factorial 20 } } } }
  13. . { then { os::println 'merge (0..5)' } }
  14. . { then { yield* { Seq { from: 0, to: 5 } } }
  15. . [Observable[Number,Error]]
  16. . { merge-map &(i) => { os::println { String i } } }
  17. . { wait-complete } }
  18. . { then { os::println 'ticker' } }
  19. . { then { tick { interval: 1000 } }
  20. . { scan (0.[Number], &(n, _) => (1 + n)) }
  21. . [Observable[Number,Error]]
  22. . { concat-map &(n) => { os::println { String n } } }
  23. . { wait-complete } } // TODO: cancel
  24. . { crash-on-error };
  25. function factorial:
  26. &(Integer) => Integer
  27. &(n) =>
  28. if (n <= 1):
  29. 1,
  30. else:
  31. (n * { factorial (n - 1) });