Building a language that people want
blog.merigoux.fr2 pointsby art-w0 comments
is_descendant(A, B) ->
lists:all(fun ({Actor, Event}) ->
Event =< proplists:get_value(Actor, B, -1)
end, A).
compare(A, B) ->
A_in_B = is_descendant(A, B),
B_in_A = is_descendant(B, A),
{A_in_B,
B_in_A,
A_in_B and B_in_A,
not (A_in_B or B_in_A}}.
The function `is_descendant` is nearly a translation of your APL code. I'm not convinced that we need APL on the Beam, for the quality of this VM certainly isn't in its array processing capabality... but I was expecting the argument "such an array-oriented language would motivate improvements in this direction", which is definitively true! all(_, []) -> true.
all(Pred, [X | Xs]) -> Pred(X) andalso all(Pred, Xs).
get_value(_, [], Default) -> Default;
get_value(K, [{K, V} | _], _) -> V;
get_value(K, [_ | Rest], Default) -> get_value(K, Rest, Default). return f(a, b, c) # tailcall on f
return f(g(b)) # tailcall on f
return f(a, b, c) + 0 # tail call on +
The last function to be called before a return is tailcall. That's it. Nothing more. It doesn't matter that the return "expression" can be more complex, only the last call is concerned. It's a simple rule. hello(N) ->
Name = <em><? N ?></em>,
<#>
<p>Hello <? Name ?></p>
<p>The <#></#> lets you group
multiple elements, that don't
have a parent, as a single value.</p>
</#>.
(Whether the <X></X> is doing simple string interpolation, or is HTML-smart is left for the reader to decide -- it's certainly overkill for server-side only code.)
- https://arcan-fe.com/ which introduces a new protocol for TUI applications, which leads to better interactions across the different layers (hard to describe! but the website has nice videos and explanations of what is made possible)
- Shelter, a shell with reproducible operations and git-like branches of the filesystem https://patrick.sirref.org/shelter/index.xml