BiwaScheme JavaScript API
Moved to reference.md
Type conversion
Scheme number == JavaScript number
Scheme string == JavaScript string
Scheme vector == JavaScript array
Scheme nil =
BiwaScheme.nil
Scheme pair =
BiwaScheme.Pair
- make a pair in js :
new BiwaScheme.Pair(1, 2)
- check x is a pair :
BiwaScheme.isPair(x)
(returnsfalse
for nil) - check x is a proper list :
BiwaScheme.isList(x)
(returnstrue
for nil) - pair -> js array :
list.to_array()
- js array -> list (shallow):
BiwaScheme.array_to_list(1, 2, [3])
=>(list 1 2 (vector 3 4))
- js array -> list (deep):
BiwaScheme.deep_array_to_list(1, 2, [3])
=>(list 1 2 (list 3 4))
- alist -> js obj :
BiwaScheme.alist_to_js_obj(alist)
- eg.
'((a 1) (b 2))
is converted to{a: 1, b: 2}
- eg.
- js obj -> alist :
BiwaScheme.js_obj_to_alist({a: 1, b: 2})
- make a pair in js :
Scheme symbol =
BiwaScheme.Symbol
- js string -> symbol :
Sym("asdf")
- symbol -> js string :
sym.name
- js string -> symbol :
Scheme function = an array, with
ary.closure_p
is set totrue
BiwaScheme.isClosure(x)
returnstrue
whenx
is a Scheme function