Skip to content

Instantly share code, notes, and snippets.

@mrsolarius
Created March 9, 2022 10:11
Show Gist options
  • Save mrsolarius/16d5f6ab60afb51ece719c7517fd140e to your computer and use it in GitHub Desktop.
Save mrsolarius/16d5f6ab60afb51ece719c7517fd140e to your computer and use it in GitHub Desktop.
Comment faire une fonction d'inversion de liste en Erlang ?
% Implementer :
% Spec : inv/1.
% inv(L) renvoie la liste inverse de L
%
% Exemple :
% inv([1,2,3]) = [3,2,1]
% Analyse
% sur L : 2 cas
% 1) L = [] : dans se cas renvoie d'une liste vide
inv([])->[];
% 2) L =/= [] : L = [Pr|Fin]
inv([Pr|Fin])->inv(Fin)++[Pr].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment