Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View elbrujohalcon's full-sized avatar
🇪🇸
Working from Catalunya

Brujo Benavides elbrujohalcon

🇪🇸
Working from Catalunya
View GitHub Profile
@elbrujohalcon
elbrujohalcon / list_exceptions.md
Last active June 6, 2021 09:58
Exceptions from the lists module
Function No Fun Bad Fun
all/2 badfun badarity
any/2 badfun badarity
dropwhile/2 badfun badarity
filter/2 function_clause function_clause
filtermap/2 badfun badarity
flatmap/2 badfun badarity
foreach/2 badfun badarity
map/2 badfun badarity
@Joakineee
Joakineee / w2lists.erl
Last active May 16, 2020 09:37
Tail recursive lists
-module(w2lists).
-export([prod/1,mymax/1,test/0]).
%Moddified according Elbrujohalcon:
%Removed the "list is emty" function clause as we will let it crash.
%prod([]) ->
% "list is empty";
prod([H|T]) ->
prod(T,H).
-module(lists2).
-export([join/2,concat/1,member/2,sort/1,sort/2,perms/1]).
-export([join_test/0,concat_test/0,member_test/0,sort_test/0,perms_test/0]).
%% Join %%%
join(L1, L2) when is_list(L1), is_list(L2) ->
join_internal(lists:reverse(L1), L2).
join_internal(L1, []) -> lists:reverse(L1);
join_internal(L1, [H|T]) ->

Current Syntax

Existing map specification syntax, as was introduced in 17.0, allows the following different syntaxes:

  • map() or #{}: the type of any map (of any size).

  • #{a => integer(), b => list()}

A map that may only contain keys a and b. If it contains a key a, then it must be mapped to an integer value. Analogously for b.