Skip to content

Commit

Permalink
Add list and eval
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Oct 9, 2023
1 parent f45dc4c commit f95e55e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions auto_editor/lang/palet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,8 @@ def my_eval(env: Env, node: object) -> Any:
"keyword?": is_keyw,
"keyword->string": Proc("keyword->string", lambda v: v.val.val, (1, 1), is_keyw),
"string->keyword": Proc("string->keyword", QuotedKeyword, (1, 1), is_str),
# lists
"list": Proc("list", lambda *a: Quoted(a), (0, None)),
# vectors
"vector": Proc("vector", lambda *a: list(a), (0, None)),
"make-vector": Proc(
Expand Down Expand Up @@ -1618,6 +1620,11 @@ def my_eval(env: Env, node: object) -> Any:
"var-exists?": Proc("var-exists?", lambda sym: sym.val in env, (1, 1), is_symbol),
"rename": Syntax(syn_rename),
"delete": Syntax(syn_delete),
"eval": Proc("eval",
lambda tl: my_eval(env, tl.val) if type(tl) is Quoted
else (my_eval(env, tl) if type(tl) is Sym else tl),
(1, 1)
),
})
# fmt: on

Expand Down
1 change: 1 addition & 0 deletions resources/scripts/scope.pal
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@
(assert (equal? (map add1 '(3 4 5)) '(4 5 6)))

(assert (equal? ('(3 4 5 6) 0 4 2) '(3 5)))
(assert (equal? (eval '(+ 3 4)) 7))

0 comments on commit f95e55e

Please sign in to comment.