Packages
kirala_l4u
0.1.1
An embedded lisp interpreter based on the gleam implementation of MAL lisp.
Current section
Files
Jump to
Current section
Files
src/examples@l4u@test_l4u.erl
-module(examples@l4u@test_l4u).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([main/0]).
-spec bif_hello(list(l4u@l4u_type:expr()), l4u@l4u_type:env()) -> l4u@l4u_type:expr().
bif_hello(Exprs, Env) ->
Names = begin
_pipe = gleam@list:map(Exprs, fun(E) -> l4u@l4u_core:pstr(E) end),
gleam@string:join(_pipe, <<", "/utf8>>)
end,
Message = <<<<"Hello, "/utf8, Names/binary>>/binary, "!!"/utf8>>,
{with_env, {string, Message}, Env}.
-spec bsf_hello_special_form(list(l4u@l4u_type:expr()), l4u@l4u_type:env()) -> l4u@l4u_type:expr().
bsf_hello_special_form(Exprs, Env) ->
Names = begin
_pipe = gleam@list:map(Exprs, fun(E) -> l4u@l4u_core:pstr(E) end),
gleam@string:join(_pipe, <<", "/utf8>>)
end,
Message = <<<<"Hello, "/utf8, Names/binary>>/binary, "!!"/utf8>>,
{with_env, {string, Message}, Env}.
-spec main() -> binary().
main() ->
Bif = fun(Name, F) -> {Name, {bif, l4u@l4u_core:description(Name), F}} end,
Bsf = fun(Name@1, F@1) ->
{Name@1, {bispform, l4u@l4u_core:description(Name@1), F@1}}
end,
Defs = [Bif(<<"hello_fn"/utf8>>, fun bif_hello/2),
Bsf(<<"hello_special_form"/utf8>>, fun bsf_hello_special_form/2)],
L4uobj = l4u@l4u:start_and_generate_main_l4u(Defs),
l4u@l4u:l4u_repl(L4uobj, <<"l4u> "/utf8>>).