Created
March 9, 2022 09:55
-
-
Save mrsolarius/b7077da37d7108efad380238647875cb to your computer and use it in GitHub Desktop.
Comment crée une séquance de nombre en Erlang ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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