Skip to content

Commit

Permalink
Add join procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Sep 30, 2023
1 parent ef08114 commit e56e4bb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions auto_editor/lang/palet.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,13 @@ def number_to_string(val: Number) -> str:
return f"{val}"


def palet_join(v: Any, s: str) -> str:
try:
return s.join(v)
except Exception:
raise MyError("join: expected string?")


dtype_map = {
Sym("bool"): np.bool_,
Sym("int8"): np.int8,
Expand Down Expand Up @@ -1500,6 +1507,7 @@ def my_eval(env: Env, node: object) -> Any:
"title": Proc("title", str.title, (1, 1), is_str),
"lower": Proc("lower", str.lower, (1, 1), is_str),
"upper": Proc("upper", str.upper, (1, 1), is_str),
"join": Proc("join", palet_join, (2, 2), is_vector, is_str),
# format
"char->int": Proc("char->int", lambda c: ord(c.val), (1, 1), is_char),
"int->char": Proc("int->char", Char, (1, 1), is_int),
Expand Down

0 comments on commit e56e4bb

Please sign in to comment.