Add Freeze/Thaw page under CEK Machine with live demo
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Documents and demonstrates serializable CEK state. Type an expression, step to any point, click Freeze to see the frozen SX. Click Thaw to resume from the frozen state and get the result. - New page at /sx/(geography.(cek.freeze)) - Nav entry under CEK Machine - Interactive island demo with step/run/freeze/thaw buttons - Documentation: the idea, freeze format, thaw/resume, what it enables Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -692,6 +692,9 @@ PRIMITIVES["number?"] = lambda x: isinstance(x, (int, float)) and not isinstance
|
||||
PRIMITIVES["string?"] = lambda x: isinstance(x, str)
|
||||
PRIMITIVES["list?"] = lambda x: isinstance(x, _b_list)
|
||||
PRIMITIVES["dict?"] = lambda x: isinstance(x, _b_dict)
|
||||
PRIMITIVES["boolean?"] = lambda x: isinstance(x, bool)
|
||||
PRIMITIVES["symbol?"] = lambda x: isinstance(x, Symbol)
|
||||
PRIMITIVES["keyword?"] = lambda x: isinstance(x, Keyword)
|
||||
PRIMITIVES["continuation?"] = lambda x: isinstance(x, Continuation)
|
||||
PRIMITIVES["empty?"] = lambda c: (
|
||||
c is None or c is NIL or
|
||||
@@ -930,6 +933,12 @@ parse_int = PRIMITIVES["parse-int"]
|
||||
upper = PRIMITIVES["upper"]
|
||||
has_key_p = PRIMITIVES["has-key?"]
|
||||
dict_p = PRIMITIVES["dict?"]
|
||||
boolean_p = PRIMITIVES["boolean?"]
|
||||
symbol_p = PRIMITIVES["symbol?"]
|
||||
keyword_p = PRIMITIVES["keyword?"]
|
||||
number_p = PRIMITIVES["number?"]
|
||||
string_p = PRIMITIVES["string?"]
|
||||
list_p = PRIMITIVES["list?"]
|
||||
dissoc = PRIMITIVES["dissoc"]
|
||||
index_of = PRIMITIVES["index-of"]
|
||||
lower = PRIMITIVES["lower"]
|
||||
@@ -4607,11 +4616,11 @@ def cek_serialize_value(val):
|
||||
return val
|
||||
elif sx_truthy(string_p(val)):
|
||||
return val
|
||||
elif sx_truthy((type_of(val) == 'boolean')):
|
||||
elif sx_truthy(boolean_p(val)):
|
||||
return val
|
||||
elif sx_truthy((type_of(val) == 'symbol')):
|
||||
elif sx_truthy(symbol_p(val)):
|
||||
return val
|
||||
elif sx_truthy((type_of(val) == 'keyword')):
|
||||
elif sx_truthy(keyword_p(val)):
|
||||
return val
|
||||
elif sx_truthy(list_p(val)):
|
||||
return map(cek_serialize_value, val)
|
||||
@@ -4653,15 +4662,15 @@ def cek_thaw_value(val):
|
||||
return val
|
||||
elif sx_truthy(string_p(val)):
|
||||
return val
|
||||
elif sx_truthy((type_of(val) == 'boolean')):
|
||||
elif sx_truthy(boolean_p(val)):
|
||||
return val
|
||||
elif sx_truthy((type_of(val) == 'symbol')):
|
||||
elif sx_truthy(symbol_p(val)):
|
||||
return val
|
||||
elif sx_truthy((type_of(val) == 'keyword')):
|
||||
elif sx_truthy(keyword_p(val)):
|
||||
return val
|
||||
elif sx_truthy((list_p(val) if not sx_truthy(list_p(val)) else ((not sx_truthy(empty_p(val))) if not sx_truthy((not sx_truthy(empty_p(val)))) else ((type_of(first(val)) == 'symbol') if not sx_truthy((type_of(first(val)) == 'symbol')) else (symbol_name(first(val)) == 'primitive'))))):
|
||||
elif sx_truthy((list_p(val) if not sx_truthy(list_p(val)) else ((not sx_truthy(empty_p(val))) if not sx_truthy((not sx_truthy(empty_p(val)))) else (symbol_p(first(val)) if not sx_truthy(symbol_p(first(val))) else (symbol_name(first(val)) == 'primitive'))))):
|
||||
return get_primitive(nth(val, 1))
|
||||
elif sx_truthy((list_p(val) if not sx_truthy(list_p(val)) else ((not sx_truthy(empty_p(val))) if not sx_truthy((not sx_truthy(empty_p(val)))) else ((type_of(first(val)) == 'symbol') if not sx_truthy((type_of(first(val)) == 'symbol')) else (symbol_name(first(val)) == 'lambda'))))):
|
||||
elif sx_truthy((list_p(val) if not sx_truthy(list_p(val)) else ((not sx_truthy(empty_p(val))) if not sx_truthy((not sx_truthy(empty_p(val)))) else (symbol_p(first(val)) if not sx_truthy(symbol_p(first(val))) else (symbol_name(first(val)) == 'lambda'))))):
|
||||
return make_lambda(nth(val, 1), nth(val, 2), {})
|
||||
elif sx_truthy(list_p(val)):
|
||||
return map(cek_thaw_value, val)
|
||||
|
||||
Reference in New Issue
Block a user