observ.esl 779 B

1234567891011121314151617181920212223242526272829
  1. ((lambda ()
  2. (function Var (val)
  3. (return ((require "observ") val)))
  4. (function Arr ()
  5. (var values (Array.prototype.slice.call arguments 0))
  6. (return ((require "observ-array") values)))
  7. (= Arr.from (lambda (values-array)
  8. (return ((require "observ-array") values-array))))
  9. (function Obj ()
  10. (var args (Array.prototype.slice.call arguments 0))
  11. (if (== 1 (% args 2)) (throw (Error "odd number of args to Obj")))
  12. (return ((require "observ-struct")
  13. (args.reduce
  14. (lambda (x y i)
  15. (if (== 1 (% i 2)) (= (get x (get args (- i 1))) y))
  16. (return x))
  17. (object)))))
  18. (= Obj.from (lambda (values-object)
  19. (return ((require "observ-struct") values-object))))
  20. (return (object "Var" Var "Arr" Arr "Obj" Obj))
  21. ))