~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/syntax_tools/examples/test.erl

  • Committer: Bazaar Package Importer
  • Author(s): Erlang Packagers, Sergei Golovan
  • Date: 2006-12-03 17:07:44 UTC
  • mfrom: (2.1.11 feisty)
  • Revision ID: james.westby@ubuntu.com-20061203170744-rghjwupacqlzs6kv
Tags: 1:11.b.2-4
[ Sergei Golovan ]
Fixed erlang-base and erlang-base-hipe prerm scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%
 
2
%% This is a test file
 
3
%%
 
4
 
 
5
-module(test).
 
6
 
 
7
-export([nrev/1]).
 
8
 
 
9
%% Just a naive reverse function in order
 
10
%% to get a code example with some comments.
 
11
 
 
12
nrev([X | Xs]) ->
 
13
    append(X, nrev(Xs));  % Quadratic behaviour
 
14
nrev([]) ->
 
15
    %% The trivial case:
 
16
    [].
 
17
 
 
18
  %% We need `append' as a subroutine:
 
19
 
 
20
append(Y, [X | Xs]) ->
 
21
    [X | append(Y, Xs)];    % Simple, innit?
 
22
append(Y, []) ->
 
23
    [Y].    % Done.
 
24
 
 
25
%% ---- end of file ----