Sha256: 6940177f435b820efff6f123047790332c2e8838cd429e8d704c7e4ce06c229c

Contents?: true

Size: 648 Bytes

Versions: 84

Compression:

Stored size: 648 Bytes

Contents

-module(grade_school).

-export([add/3, get/2, sort/1, new/0]).

%% Define the grade school type
-type school() :: [{integer(),[string(),...]}].

-spec add(string(), integer(), school()) -> school().
add(Name, Grade, School) ->
  case get(Grade, School) of
    [] ->
      orddict:store(Grade, [Name], School);
    Class ->
      orddict:store(Grade, ordsets:add_element(Name, Class), School)
  end.

-spec get(integer(), school()) -> [string()].
get(Grade, Students) ->
  case orddict:find(Grade, Students) of
    {ok, Class} -> Class;
    _ -> []
  end.

-spec sort(school()) -> school().
sort(S) ->
  S.

-spec new() -> school().
new() ->
  [].

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
trackler-2.0.6.28 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.27 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.26 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.25 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.24 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.23 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.22 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.21 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.20 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.19 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.18 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.17 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.16 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.15 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.14 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.13 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.12 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.11 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.10 tracks/erlang/exercises/grade-school/example.erl
trackler-2.0.6.9 tracks/erlang/exercises/grade-school/example.erl