Skip to content

Instantly share code, notes, and snippets.

@mrsolarius
Created March 9, 2022 09:55
Show Gist options
  • Save mrsolarius/b7077da37d7108efad380238647875cb to your computer and use it in GitHub Desktop.
Save mrsolarius/b7077da37d7108efad380238647875cb to your computer and use it in GitHub Desktop.
Comment crée une séquance de nombre en Erlang ?
% Spec : sequ/1
% sequ(X) est la liste des entiers de 1 à X
% Si X>=1, [] sinon
%
% Exemple :
% sequ(3) = [1,2,3]
% sequ(0) = []
% Analyse sur X : 2 cas
% 1) X = 0 : dans se cas renvoie d'une liste vide
sequ(0)->[];
% 2) X >0 : X = N+1
sequ(X) when X>0 -> sequ(X-1)++[X].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment